1

I've an interface like this:

interface Angle{
    value: number
}

And i was wondering if there's an elegant way to convert number to something like ClampedNumber<min, max> with two numbers instead of min and max

defrid
  • 11
  • 2

1 Answers1

1

Technically, you can make a generic type that would result in a union of min | min + 1 | ... | max - 1| max

(Is it possible to restrict number to a certain range).

But not only it seems like a complex and not so performance friendly idea. I would not recommend it because you would need to use casting a lot.

YohaiM
  • 383
  • 2
  • 9