-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Integer value comparison, minimum length array, useful? #282
Comments
There an easier way to do the min length array. [string, ...string[]] Which is much better. Notably though it can't be used in comparisons / only works if the type is being defined in the place it is. I think this is relatively new so maybe a bug |
It's a cool exploration of TS, but I don't think it's very practical. You should definitely write a blog post about it. Happy to link to it from here if you do. We could also maybe add |
What I think we could add is |
the problem I think with the const foo = (bar: [string, ...string[]]) => {}
foo(["bar"]) // no error
const bar = ["bar"];
foo(bar) // Argument of type 'string[]' is not assignable to parameter of type '[string, ...string[]]' Typescript's arbitrary type declarations and then literal comparison is the bane of my existence, lol. I spend way too much time trying to figure out ways around it. Any ideas on a work around? I'll create a ticket in typescript in the meantime though. |
The following is an exploration into the limitations of typescript's ability to perform math comparisons. The primary limitation I found was the recursion depth being limited to 45. I don't think this is particularly practical because of this limitiation, but what do you think? Is there anything useful in the following?
The text was updated successfully, but these errors were encountered: