3 ms·
In our codebase we started to disallow enums in favour of string literal types, and once folks get over the ingrained "this needs to be an enum" (coming mostly
by Shacklz 2y ago
In our codebase we started to disallow enums in favour of string literal types, and once folks get over the ingrained "this needs to be an enum" (coming mostly from other languages like Java), it's not much missed.
Enums are one of the very few things in typescript that seem to not have turned out that well, but it's relatively easy to work without them with string-literable types and such, derived from some const in case they're also needed at runtime.
- shepherdjerred 2y ago100% agree. Coming from Java I really wanted an Enum type, but string literals/discriminated unions fill that niche just fine.
- bythreads 2y agoagree enums in typescript are the devil
- revskill 2y agoCould u explain why ?