3 ms·
He is completely incorrect about the purpose of enums. It isn't to simplify changing all locations of an occurrence. It is for defining domain concepts. It is t
by yCombLinks 5y ago
He is completely incorrect about the purpose of enums. It isn't to simplify changing all locations of an occurrence. It is for defining domain concepts. It is to communicate to other code users, here is every allowed permutation of this type.
- seniorsassycat 5y agoYou can do that with sum types. type methods = 'a' | 'b' const value: methods = 'c' // error The difference is enums are also nominal, while most types are structural.
- KuhlMensch 5y agoI don't know if you are correct, but this is closest to how I think about it Mechanically, a const dictionary, or a string union might achieve the same. But semantically, an enum (sometimes) reads better.