News for hackers. Stuff that matters.
Re:Node.js adds experimental support for TypeScript by just-tom on Thursday July 25, 2024 @12:23AM (#41064685)
Nice, but without support for Enums, for me it's mostly useless.
Re:Node.js adds experimental support for TypeScript by Shacklz on Thursday July 25, 2024 @12:31AM (#41064727)
In our codebase we started to disallow enums in favour of string literal types, and once folks get over the ingrained "this needs to be an enum" (coming mostly from other languages like Java), it's not much missed.

Enums are one of the very few things in typescript that seem to not have turned out that well, but it's relatively easy to work without them with string-literable types and such, derived from some const in case they're also needed at runtime.

Re:Node.js adds experimental support for TypeScript by shepherdjerred on Thursday July 25, 2024 @01:01AM (#41064874)
100% agree. Coming from Java I really wanted an Enum type, but string literals/discriminated unions fill that niche just fine.
Re:Node.js adds experimental support for TypeScript by bythreads on Thursday July 25, 2024 @06:02AM (#41066787)
agree enums in typescript are the devil
Re:Node.js adds experimental support for TypeScript by revskill on Thursday July 25, 2024 @09:49AM (#41068673)
Could u explain why ?
Re:Node.js adds experimental support for TypeScript by azangru on Thursday July 25, 2024 @04:24AM (#41066192)
There are union types for strings; and there are plain javascript objects (typed as const) if "namespace.name" syntax is desired. With these available, what is the point of enums?
Re:Node.js adds experimental support for TypeScript by silverwind on Thursday July 25, 2024 @06:06AM (#41066809)
Namespaces are also not supported as per https://github.com/nodejs/node/blob/main/doc/api/typescript.....

I for one can can live without all these features and will be banning via eslint.

Re:Node.js adds experimental support for TypeScript by azangru on Thursday July 25, 2024 @08:45AM (#41068019)
Yes. Both namespaces and enums (and probably the "private" keyword on class methods) are an early addition to the language, which would have never been added if typescript from the very start aligned closely with Ecmascript.