When working with TypeScript, I often set types like this:
type range = 1 | 2 | 3 | 4 | 5;
By doing this, I limit the valid values for range to numbers 1, 2, 3, 4, and 5.
I have been exploring whether it is possible to add conditions to types. Rather than specifying specific values as shown above, can I do something like this instead:
type range >= 0 && range <= 5
If this cannot be achieved using a type, perhaps an interface would work. My goal is to validate values based on conditions rather than listing out individual literals as seen earlier.