|
|
|
|
|
by zogrodea
703 days ago
|
|
My understanding of the comment is that it’s in the context of saving an enumeration-object into a database. Like Typescript might (for example) represent enums as integers like 1, 2, 3... at runtime. What happens if you decide to store a “delivery status” enum in a database? You would just be saving a number into the database, which can be hard to understand. If it’s a string, then the value stored in the database is clearer and doesn’t depend on you being lucky with the Typescript compiler that the same enum type is compiled to the same integers after new releases. I only realised this issue now, but it’s what I understood after reading that comment. |
|
There may be a really good use case for the enum type, but I think in most cases, string type unions are clearer, easier, and less prone to errors.