Live data from Hacker News

Node.js is able to execute TypeScript files without additional configuration

nodejs.org

111–120 of 275 posts

Re: Node.js is able to execute TypeScript files without additional configuration

#112
post #97

Earlier quoted context omitted.

Maybe, are you sure Go dependencies are immune to similar attacks?

Yes, with the difference that Google would have to be compromised in order to poison the go distributable containing fmt tool. With js, it’s enough to poison any single one of the 1400 dependencies of the linter

Use biome, it doesn't have any external dependencies. eslint should have been put to rest a long time ago.

Re: Node.js is able to execute TypeScript files without additional configuration

#113

Earlier quoted context omitted.

Yeah agreed - saying "node can execute typescript files" is a bit misleading. More accurate would be "node can find-and-replace type information with spaces from .ts files and try and executing them as if they were plain JavaScript" I suspect this would only handle the most rudimentary and basic typescript files. Once you start using the type system more extensively I suspect this will blow-up in your face. It's kind…

Just to give context here, NodeJS doesnt support enums, namespaces and class parameter properties. All of these have been described as regrets by Anders Hejsberg, and none of them prevent advanced use of the type system at all. Source: 49m 43s https://m.youtube.com/watch?v=NrEW7F2WCNA

Yes, they regret them because they hinder adoptions. Why? Because nobody chose to add TSC with all features in their runtime because TSC is extremely slow.

They know they can skyrocket adoption by limiting the language. That's the reason they regret it. This is just a strategy to increase adoption. Not because they are bad features. They are in fact very useful, and you should not stop using them just because your favorite runtime decided to go the easy way and only supporting a subset of TS by stripping types. You should rather switch the runtime instead of compromising your codebase.

Re: Node.js is able to execute TypeScript files without additional configuration

#114
post #14

Earlier quoted context omitted.

Yeah agreed - saying "node can execute typescript files" is a bit misleading. More accurate would be "node can find-and-replace type information with spaces from .ts files and try and executing them as if they were plain JavaScript" I suspect this would only handle the most rudimentary and basic typescript files. Once you start using the type system more extensively I suspect this will blow-up in your face. It's kind…

> node can find-and-replace type information with spaces from .ts files and try and executing them as if they were plain JavaScript That’s what all the other tools like ts-node and tsx do already. I’m not sure what more are you expecting to do? Typescript is build time type checked, there is no runtime component to TypeScript. If you want type checking you run tsc. I think this is a great step in the right direction…

> I think this is a great step in the right direction by node

I think it's the opposite. It will be a net negative, since people will now run TS by default without type checking. Wasting so much time chasing weird runtime errors - just to end up running the full blown TSC type checking again. They will also write very different TS now, trying to workaround the limitation and arguably very useful features like Enums, constructor properties, etc. This has real negative effects on your codebase if you rely on these, just because Node chose to support only a subset.

It's interesting to see the strategy now and to see people even gaslighting people into believing no type checks and less features is a good thing. All just because of one root cause - TSC being extremely slow.

Re: Node.js is able to execute TypeScript files without additional configuration

#115
post #79

Earlier quoted context omitted.

As a quick aside, “them” is an object pronoun, not a subject pronoun. The correct word you needed is “they”. You couldn’t phrase your original question as a statement “Them have though.” That’s often a quick test for valid English grammar. With the correct pronoun, it makes more sense: “They have though.” As another example, take this sentence: “Have you seen them though?” “You” is the subject of that sentence, and “…

Them is fine. It's short for "Have them [Node bozos improved it], though?" Or, equally likely it, refers to deno and bun ("deno and bun has really made Node focus and improve", "Have them (deno and bun) really made Node focus and improve, though?")

That is nonstandard English, at best. It's found in some uncommon dialects.

Without the expansion I don't know of any native English speaker who would say it.

Re: Node.js is able to execute TypeScript files without additional configuration

#116
post #43

Earlier quoted context omitted.

> (although do you still need to use the .mjs hack?) Syntax detection is enabled by default in v22.7.0, v20.19.0: https://nodejs.org/api/packages.html#syntax-detection Sounds like the obvious correct solution, making .cjs and .mjs obsolete - unless of course someone uses import() statements exclusively, in which case I need to ask: why?

It is surprising for me to see these features finally being added to Node after such a long time. Especially so when I remember reading discussion after discussion about how something like this wasn't possible. I touched on this in a blog post some time ago [1]. Glad Node is catching up. [1] https://kilo.bytesize.xyz/an-incorrect-specification

I don't see in your blogpost any sources cited regarding anyone saying that ES modules were infeasible.

Additionally, io.js actually forked off due to internal drama which started with Ben Noordhuis having changed some pronouns here and there and people wanting to cancel him for that, to which he picked up his toys and left the sandbox.

It so happened that aside from being competent himself, he had competent people on his side, which eventually forced those governing Node.js to concede.

Bun is just a cash grab in comparison.

Re: Node.js is able to execute TypeScript files without additional configuration

#117
post #58

I wish browsers also supported directly running typescript files.

Someday! https://github.com/tc39/proposal-type-annotations

That is the real reason we get a less feature-rich TypeScript in the future and Node not supporting full TypeScript. Because they want to be supported by browser.

Re: Node.js is able to execute TypeScript files without additional configuration

#119

Earlier quoted context omitted.

Yes, with the difference that Google would have to be compromised in order to poison the go distributable containing fmt tool. With js, it’s enough to poison any single one of the 1400 dependencies of the linter

Use biome, it doesn't have any external dependencies. eslint should have been put to rest a long time ago.

Good advice. That was my conclusion as well after years of fighting with eslint.

Re: Node.js is able to execute TypeScript files without additional configuration

#120
post #47

Is there any movement in the node world for the runtime to be able to ascertain types? Obviously nodejs doesn't do this, but does Bun or Deno or are there plans for any of this in the future?

i don’t think you’ll see this at the typescript level, and you won’t see anything like this that compiles to javascript. specifically, compiling typescript to javascript with runtime checks would not actually be very useful. typescript is pretty ambiguous about a lot of the things that would need explicit definition for runtime safety, and anyways we already have tools for that - it’s called zod. and comprehensive ch…

> you won’t see anything like this that compiles to javascript

https://github.com/microsoft/TypeScript/issues/47658

Post reply on HN