Live data from Hacker News

Node.js adds experimental support for TypeScript

github.com

11–20 of 570 posts

Re: Node.js adds experimental support for TypeScript

#11
It's about time for TC39 and Microsoft to standardize TypeScript as part of JavaScript. Not "types as comments" either, but actually TypeScript, minus the non-standard runtime semantics and modulo whatever changes are necessary to integrate the grammar.

So many runtimes and tools are integrating TypeScript now, and with multiple implementations, that a real standard is necessary. It'll be much harder to evolve TypeScript because it'll have to stay backwards compatible, but it's grown to that point now, imo.

Re: Node.js adds experimental support for TypeScript

#13

Nice to see Node.js getting parity on this with Deno and Bun

This reminds me of io.js situation, where in the end major fork changes were incorporated into Node. This is why I am comfortable staying with Node and npm for my projects - the features will eventually trickle down anyway.

But in the meantime you suffer for it.

How many days have you spent on webpack config? Or the package.json type property? Or yarn/pnpm/etc particulars?

I have spent too many.

Bun is quite nice.

Re: Node.js adds experimental support for TypeScript

#14

Nice to see Node.js getting parity on this with Deno and Bun

On the topic of typescript - yes. However Bun has a lot more tools baked in than Node does at (bun test for instance). Would be real nice to see Node start adopting more ideas from Bun and others.

Give node a closer look, it's been quietly accruing those features.

node has a built in test runner now

https://nodejs.org/api/test.html

Re: Node.js adds experimental support for TypeScript

#15
post #4

My favorite deno feature is coming to node directly. Awesome! Maybe this means I don't always have to install esbuild to strip types - very excited how this will make writing scripts in TypeScript that much easier to use. I lately have been prefering Python for one off scripts, but I do think personally TypeScript > Python wrt types. And larger scripts really benefit from types especially when looking at them again a…

btw if anyone is looking to run ts on node, there is tsx. there is also ts-node but i prefer tsx.

https://github.com/privatenumber/tsx

Re: Node.js adds experimental support for TypeScript

#16
post #5

So how does this work in practice? Does it strip types and yolo trying to run or will it spit out type errors?

Why would you describe that "yolo"? If you're writing TS, you already have a TS linter that checks whether code has typing problems or not (at least, I certainly hope you do?). It's not really Node's job to do that linting, its job is to execute the JS that's hiding in the TS. It'd be "handy" if it did, but it'd also be a bit weird when there are already TS linting tools. It'd just hold up landing any sort of TS support that much longer.

Re: Node.js adds experimental support for TypeScript

#17
post #6

support for typescript as long as you are only using it for type checking, not if you are also using features that are not supported in the javascript version you are targeting.

That is what people use TypeScript for generally.

If you need JS syntax features that Node.js doesn't support you can use tsc, babel, etc.

Because obviously unsupported features are unsupported, whether JS or TS.

Re: Node.js adds experimental support for TypeScript

#18

It's about time for TC39 and Microsoft to standardize TypeScript as part of JavaScript. Not "types as comments" either, but actually TypeScript, minus the non-standard runtime semantics and modulo whatever changes are necessary to integrate the grammar. So many runtimes and tools are integrating TypeScript now, and with multiple implementations, that a real standard is necessary. It'll be much harder to evolve TypeSc…

its about time google chrome started making a typescript engine maybe? and get rid of JS in phases?

Re: Node.js adds experimental support for TypeScript

#19
post #5

So how does this work in practice? Does it strip types and yolo trying to run or will it spit out type errors?

If you read the third sentence of the PR, it says:

> During the transpilation process, no type checking is performed, and types are discarded

Re: Node.js adds experimental support for TypeScript

#20

It's about time for TC39 and Microsoft to standardize TypeScript as part of JavaScript. Not "types as comments" either, but actually TypeScript, minus the non-standard runtime semantics and modulo whatever changes are necessary to integrate the grammar. So many runtimes and tools are integrating TypeScript now, and with multiple implementations, that a real standard is necessary. It'll be much harder to evolve TypeSc…

This has been proposed for several years now, but there's been very little progress on it:

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

Post reply on HN