4 ms·
Is this what you're referring to when you're talking about more elegant alternatives? Come on. You're not going to convince anyone with this.
by Kiro 2y ago
Is this what you're referring to when you're talking about more elegant alternatives? Come on. You're not going to convince anyone with this.
- mistercow 2y agoNo, this is what I suggest for someone who wants to do something non-idiomatic because they're used to C. What I suggest in most cases is just a string union type. Edit: But for what it's worth, yes, the above is still more elegant than enums. The syntax may feel less elegant, but among other things, the above does not depart from the structural type paradigm that the rest of the language uses, all for something as simple as an enum.
- cap11235 2y agoTypescript devs love doing anything except developing scripts with types