3 ms·
I don’t understand why so many people advise against TS enums. The string variant is no different at runtime from a const of the same mapping, but they also ach
by eyelidlessness 6y ago
I don’t understand why so many people advise against TS enums. The string variant is no different at runtime from a const of the same mapping, but they also achieve nominal typing in an otherwise structural type system, which is super useful for preventing ambiguity errors
- XVincentX 6y agoSee my response above!
- moogly 6y agoI've done TypeScript for 5-6 years, in up to 100+k loc codebases, and never had a problem with enums, both with tsc and babel (so yeah, `const enum` no worky). `Object.values(SomeEnum)` is pretty handy, something you can't do with string union types.