DEV Community

Discussion on: Why TypeScript enums suck

Collapse
 
ssimontis profile image
Scott Simontis

In C#, I use something called the static enum pattern, which I first learned of from the linked blog. I find it gives me more control over enum values: casting is more explicit, I know the data types involved in the enum definition, and it is impossible to select an enum value outside of the legal range, which is a big problem in C#. Not sure if TS will let you arbitrarily cast any number to an enum, regardless of if an enum value has been defined for that number.