Replies: 1 comment 1 reply
-
Hey, thanks for sharing these ideas. I can see the convenience of having this If the use-case is to validate inputs to a function, then the current types offer a much more performant way to specify this, like so: import { Num, U } from "@rimbu/typical";
function f<N extends number>(value: N & U.Check<Num.InRange<N, 0, 10>>) {}
f(5); // <- no problem
f(14); // <- compiler error I get that this is quite a bit more complex than the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Thank you for creating this!
I was going to use union subtraction, but it goes only up to 999, and I needed to include a few numbers above that, and
Num.Add
turned out to be perfect for that:Edit:
I ended up using this, as to avoid having a dep (and I haven't checked, but it might have better performance too):
The list of numbers can be generated here.
But the original snippet still fits into this library, I think.
Beta Was this translation helpful? Give feedback.
All reactions