How to allow only certain number values for variables or constants in TypeScript?
Originally Published Here ๐!
To allow only certain number values for variables or constants, we can use a number literal union type in TypeScript.
TL;DR
// number literal union type with
// values of "0", "1", "2"
type PriorityNumbers = "0" | "1" | ...
melvingeorge-me.hashnode.dev3 min read