TypeScript enums: use cases and alternatives
In this blog post, we take a closer look at TypeScript enums:
How do they work?
What are their use cases?
What are the alternatives if we don’t want to use them?
The blog post concludes with recommendations for what to use when.
Notation
The basics of TypeScript enums
An enum defines an object
An enum defines a type
We can check exhaustiveness for enums
Enumerating members
Enums without explicitly specified values
Use cases for enums
Use case: namespace for constants with primitive values
Enum a...
Read more at 2ality.com