Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript number must be less than 1 and greater than 0

Tags:

typescript

I'm wondering if there is a way yet, in Typescript, to ensure that the value of a number is less than and/or greater than a certain value. Right now it allows you to specify a list of values, but I don't know about comparing.

This is something like what I'm looking for:

interface Input {
    value: number < 1
}
like image 356
watzon Avatar asked Sep 16 '16 21:09

watzon


People also ask

What is the range of number in typescript?

What is the range of number in typescript? Uint8ClampedArray , value ranges from 0 to 255.

How do you define a number in typescript?

In typescript, we can also represent the numbers by using Number object like as shown below. [Keyword] [Variable Name] = new Number(Value); Following is the example of using Number object to represent numbers in typescript. let num1 = new Number(446);


1 Answers

Right now there is nothing in the language to allow you to do that kind of type definition.

like image 64
toskv Avatar answered Sep 17 '22 00:09

toskv