-
-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need some help to understand string extends S
#183
Comments
(note: sometimes |
Thanks, I see, but I still don't understand why it's necessary to check this kind of assertion is the utility type export type Split<S extends string, D extends string> =
string extends S ? string[] :
S extends '' ? [] :
S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] :
[S]; In fact, if I remove the condition Sorry if I'm not clear, but it's kind of bug me 🤪 ! haha |
Because if all you know about a value is that it is
Which is incorrect. |
Ok I see ! Thanks a lot for your clear answers ! |
Hi !
First of all, thanks a lot for this library, it opened my eyes to the capacities and power of "String literal types".
I'm currently building a bunch of types to enable SQL query type extracting.
The main goal of my implementation will be to enable something like this :
Actually, I have a working prototype deeply inspired by type-fest, but I ask myself a question and I didn't find anything concrete about the use of the condition
string extends S
in some of the library types (Here).If I remove the condition
string extends S
the type is still working as expected.Can someone explain to me the intention behind this ?
Thank you!
The text was updated successfully, but these errors were encountered: