Enums
Enums are one of the few features TypeScript has that is not a type-level extension of JavaScript. Enums permit a developer to define a set of named constants. Using enums can make it easier to document intent or create a set of distinct cases.
Enums can store numeric or string values and are normally used to provide predefined values. Personally, I like to use them to define a palette of colors in a theming system, as follows:
Figure 2.4: Enums used for color palette
Moving on to another useful feature of TypeScript, let’s explore namespaces.