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