The inferred type of '... cannot be named without a reference to '../../../../node_modules/arktype/
I receive this strange message:
What's weird is that I don't see it in VSCode when editing code, but only when attepmting to build the project.
Here is the code it's referrencing:
Here
config$$
is a scope. How to properly type it?38 Replies
Here is a working example:
TS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
This is a recurring issue with TS that in the past I've found to be related to symlinks from
pnpm
, but it often seems arbitrary when it occurs- was talking to @Vanilagy about this recently. Best thing to do is just annotate the type, there's usually a relatively non-painful way to extract out what you need and do it explicitly.
Here's the TS issue: https://github.com/microsoft/TypeScript/issues/42873GitHub
The inferred type of "X" cannot be named without a reference to "Y"...
Bug Report ๐ Search Terms inferred type cannot be named, symlink node_modules ๐ Version & Regression Information I'm verifying the problem on the [email protected]. I've not tried older ...
I see. Well, I'm not good at annotating ark-things yet ๐
yesterday I even created a thread about it, but it was too way wordy ๐
I did see that lol too much to catch up on taking the weekend off ๐ฌ
sure, so I marked it "DELETE"
hoping that some cleanup process can remove it
The return type shouldn't be
Config[K]
obviously, because I need to get this type from the scope
Something like Space<{[K]: infer t}>
?
Ah, I should use asOut
probable, lmt
Some rubbish:
And it doesn't even work for some reason
Ideas?
Nah, I give upSorry I wish I had more time to take a deeper look at this haha just trying to juggle a lot right now ๐คน
Unknown Userโข16mo ago
Message Not Public
Sign In & Join Server To View
Just to make it clear. No need to read that topic. It must be deleted, and I would do it myself but I don't seem to have enough permissions
What is relevant is this link:
TS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
Would it just be this:
Config[K]
won't really work here because Config
is Partial<typeof type(config$$)>
And the idea of this "getter" is to get the type right from the scope
So I wonder how that one can be fetchedI don't understand though
That is the type of what
assert
would returnThe return type of this function is
when it's inferred. I need to get the same but directly
Oh I see. I might change your names they're very confusing
Particularly that
haha, sorry, but I used double $$ for scope and single $ for type
and thought it was a nice idea LOL
I mean you said you don't know what morphs are right? So you don't care about
asOut
obviously it's not...
yes, I don't know about morphs yet
So really all you need is
Exclude<Config[K], undefined>
or somethingand the other way? is there another way?
I mean yeah you could try and use the
/internal
import syntax to get asOut
but if you aren't using morphs it won't matter they will be equivalentWell, let me clarify then.
1) first I define scope as a set of validators:
const myScope = scope({ foo: 'string' }).compile()
2) then I convert it to a type const myType = type(myScope)
3) then I apply a function to it to get another type: const myType2 = f(myType)
e.g. partial()
Now, I need basically to get the type of an element from the myScope, as Scope[K]
, or Scope['foo']
- how to do this?
So I don't think it's important if I use morphs or not, I just need to fetch the type from a scope by key
I can do it this way I guess:
but it looks too cumbersome.Sorry still lost on this one. Can you give an example where
Exclude<Config[K], undefined>
would not give the result you want?It will work in this particular case. But it depends on the way how
Config
was made (parial applied). What if there was another tranformation of the original type?I just think what you're doing is quite hard to follow but based on what you've written that is the correct type. If for some reason you need to extract the original type from the space I guess something like the conditional you wrote is your best bet.
I will try and optimize some of these things for library authors to make them easier in the next release
Hm. Ok then. I just thought there was a way to simply take out something from the scope
as easy as I do with type
You can with a scope, not with a space though
Spaces are just collections of types, they don't have all the extra methods like
.infer
on themWell, so... when I do this, I get space then?
compile() converts scope to a space?
Yes
Ahhhh
that's it
I would really like to take part in making documentation
but at my current level of familiarity with the library, I'm afraid I will be barely useful
I'd say it's the opposite
You have things to do and no idea how does the lib work
wdym sorry?
Documentation ismade for people like you
Not us who already know every drop
Sure.
But I know a lot of cases when users were creating documentation and even writing books
So if you collect all our answers as markdown that's half work done
Then a bit of polish by you so you understand better and by us so it's more correct and ideomatic
I appreciate you wanting to help! Hopefully once I release some baseline docs with beta you can help augment them as you gain more familiarity with ArkType!
@OnkelTem so while you are still new, ask 5-10 stupid questions you can imagine yourself asking for actual work
(but don't know answer yet)