DEV Community

Discussion on: 9 tricks that separate a pro Typescript developer from an noob ๐Ÿ˜Ž

Collapse
 
kc900201 profile image
KC

I've read from other articles that enums are to be avoided when it comes to data structuring in TypeScript. Lemme know if you have a different opinion. Overall, this is a well summarized reference and thanks for sharing.

Collapse
 
ruppysuppy profile image
Tapajyoti Bose

Yeah as mentioned in the article, enums may break pre-existing data in the DB if new values are introduced (if you don't explicitly mention the mapped values). If you plan to use enums, mapping them to a specific value is a non-negotiable, but you can always use constant objects, mapping the same values.

I personally prefer using enums & haven't run into any issues over the past 4 years apart from the unmapped enums being overwritten