Other literal types

TypeScript also supports boolean, numbers as literals, e.g.:

type OneToFive = 1 | 2 | 3 | 4 | 5;
type Bools = true | false;

Use cases

Valid use cases for string literal types are:

String based enums

TypeScript enums are number based. You can use string literals with union types to mock a string based enum as we did in the CardinalDirection example above. You can even generate a Key:Value structure using the following function: