Enums vs String Literals in TypeScript

Enums help to define a set of named constants. Using enums can make it easier to document intent, or create a set of distinct cases.

Enums are one of the few features TypeScript has which is not a type-level extension of JavaScript.

TypeScript 2.4 implemented one of the most requested features: string enums, or, to be more precise, enums with string-valued members.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store