3 ms·
This is the way, because iterating enums produces odd results due to a bidirectional mapping. I had always used enums in TS until this year, but union literals
by lucasyvas 5y ago
This is the way, because iterating enums produces odd results due to a bidirectional mapping.
I had always used enums in TS until this year, but union literals are better.
I create my own enums with const objects, compute the type based off the object's values. So very similar this, just with an object as the source instead of an array.
- sli 5y agoIterating over an enum in TypeScript always felt like code smell to me because of the filtering code I'd have to write to deal with the bidirectional mapping.