Friday, November 29, 2019

TypeScript - String literal types


Sometimes we'd like to limit input string to some set of values.

We can validate string by ourselves. It is easy, but sometime it is annoying.

The good news is that TypeScript 1.8 has supported 'String Literal Types'. Using it, we can define the set of string value in type level. Check the link for more detail.