News for hackers. Stuff that matters.
Re:TypeScript enums: use cases and alternatives by Kiro on Monday January 20, 2025 @11:36AM (#42770339)
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.
Re:TypeScript enums: use cases and alternatives by mistercow on Monday January 20, 2025 @11:41AM (#42770384)
No, 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.

Re:TypeScript enums: use cases and alternatives by cap11235 on Monday January 20, 2025 @02:41PM (#42772272)
Typescript devs love doing anything except developing scripts with types