News for hackers. Stuff that matters.
Re:TypeScript enums: use cases and alternatives by rvz on Monday January 20, 2025 @05:57AM (#42767353)
> After almost a decade of TypeScript my recommendation is to not use TypeScript enums.

Or don't use TypeScript / JavaScript at all and even Node.js and be done with this language. Especially in the backend. Full stop.

The language itself is not only a bolt-on superset on top of another horrific language (JavaScript), it is still gives the programmer ways to shoot themselves in the foot and still has a unsound type system compared with the likes of Kotlin and Go.

This is even before talking about the still immature ecosystem around it.

> Enums is going to make your TypeScript code not work in a future where TypeScript code can be run with Node.js or in browser when typings are added to JavaScript[1]

There you go. TypeScript will just become like CoffeeScript and will be replaced with ...JavaScript (with type annotations).

Re:TypeScript enums: use cases and alternatives by Vinnl on Monday January 20, 2025 @06:21AM (#42767516)
I can assure you that I can find a way to shoot myself in the foot in any language.
Re:TypeScript enums: use cases and alternatives by rvz on Monday January 20, 2025 @09:21AM (#42768996)
With any language, you can (which isn't my point). The point is which one is the easiest and its with anything in proximity of the whole JavaScript ecosystem including TypeScript.

It really says a lot about how immature it is especially for backend and just by even hearing the complaints about TypeScript 'enums' tells me all I need to know.

So what other foot-guns have the JS / TS ecosystem have hidden?

Re:TypeScript enums: use cases and alternatives by n144q on Monday January 20, 2025 @09:02AM (#42768821)
Dude, why are you here? Your comment is just a (very opionated) rant and not providing any value for anybody in the discussion.