-
-
Notifications
You must be signed in to change notification settings - Fork 506
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
A range of numbers #123
Comments
I think we could do something like what's done here: microsoft/TypeScript#15480 (comment) (don't forget to 👍🏻 on that issue) But it would be limited to a range of 40. That should be enough for many use-cases though. |
What about this, stolen from stackoverflow and modified to work properly:
Some testing:
|
Seems like it's now possible with TypeScript 4.8: https://twitter.com/anuraghazru/status/1573328100246822917 Nice work, @anuraghazra |
I’ve started working on implementing a solution similar to microsoft/TypeScript#15480 (comment), with options to control the step size, if the range is inclusive, and if the range should be a union instead of a tuple (using Still trying to figure out how to infer type FiveNumbers = Range<5>;
//=> [0, 1, 2, 3, 4] I also think it would be worth adding a |
👍 |
Another solution: https://stackoverflow.com/a/39495173/10796681 |
Something built in like this
https://stackoverflow.com/questions/39494689/is-it-possible-to-restrict-number-to-a-certain-range
Instead of
It would be nice to be able to do
Upvote & Fund
The text was updated successfully, but these errors were encountered: