DEV Community

Discussion on: We don't have to use Enums on TypeScript? 【Discussion】

Collapse
 
jkierem profile image
Juan Miguel Gomez • Edited

In my opinion, normally, one more object in memory is not enough to be considered a problem. As with everything, enums serve a purpose: having a type with restricted runtime representation. Unions serve this purpose too but are based around literals. So unions can be seen as anonymous enums.
Personally, I would like to have haskell/rust/scala enums, where the members of the enum can store values and could be destructured

Also keep in mind there is a proposal for enums in JS so this overhead of TS adding may become valid JS

Collapse
 
peerreynders profile image
peerreynders • Edited

That proposal has been inactive since 2018 and isn't referenced anywhere on the TC39 stages - so it's unlikely to go anywhere.

Another proposal seems to be in the works but isn't a match with the contemporary TypeScript version (which could be deliberate; ADT support).