News for hackers. Stuff that matters.
Re:Node.js adds experimental support for TypeScript by yamumsahoe on Thursday July 25, 2024 @12:09AM (#41064623)
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 by jessym on Thursday July 25, 2024 @12:55AM (#41064840)
I second this. The tsx library is zero config and always "just works" in my experience, which puts it miles ahead of ts-node, imo.
Re:Node.js adds experimental support for TypeScript by iansinnott on Thursday July 25, 2024 @01:38AM (#41065055)
Seconded again. While tsx usually just works ts-node almost never just works. tsx is perhaps unfortunately named though so it may confuse people at first since it has nothing to do with jsx syntax.
Re:Node.js adds experimental support for TypeScript by jimvdv on Thursday July 25, 2024 @01:59AM (#41065162)
Thank you for bringing this up, I almost ignored this project since I assumed it had something to do with TypeScript + JSX.

The JS ecosystem sure struggles with naming things.

Re:Node.js adds experimental support for TypeScript by tommica on Thursday July 25, 2024 @02:19AM (#41065287)
The _programming_ ecosystem sure struggles with naming things.
Re:Node.js adds experimental support for TypeScript by jimvdv on Thursday July 25, 2024 @09:34AM (#41068516)
Fair enough
Re:Node.js adds experimental support for TypeScript by nikeee on Thursday July 25, 2024 @06:59PM (#41074339)
I own the npm package node-ts, which has thousands of installs per week just because people confuse it with ts-node.

I didn't intend to typo-squat. Actually, my package is older than ts-node and was just a pun because it is an API for TeamSpeak written in TypeScript.

Re:Node.js adds experimental support for TypeScript by tills13 on Thursday July 25, 2024 @12:50PM (#41070758)
It's named as such to mirror `npx`
Re:Node.js adds experimental support for TypeScript by silverwind on Thursday July 25, 2024 @05:25AM (#41066599)
tsx has very slow startup performance, I prefer https://github.com/swc-project/swc-node which is around twice as fast.
Re:Node.js adds experimental support for TypeScript by herpdyderp on Thursday July 25, 2024 @07:56AM (#41067541)
Does swc-node work with code coverage calculation libraries? For a long time tsx didn’t (and it’s still pretty finicky) so that kept me from using it.
Re:Node.js adds experimental support for TypeScript by silverwind on Thursday July 25, 2024 @10:26AM (#41069043)
Not sure what features those need, but at least the stack traces are correct in swc-node, so maybe worth a try.
Re:Node.js adds experimental support for TypeScript by dimgl on Thursday July 25, 2024 @06:42PM (#41074228)
We have not seen this whatsoever. How big is your project? `tsx` is almost instantaneous in a server-side project of ours.
Re:Node.js adds experimental support for TypeScript by silverwind on Friday July 26, 2024 @01:57PM (#41080703)
A hello world here takes 400ms on tsx and 250ms on swc-node for me.

Basically it boils down to swc being faster than esbuild, see their benchmarks:

https://swc.rs/docs/benchmarks

Re:Node.js adds experimental support for TypeScript by wruza on Thursday July 25, 2024 @06:12AM (#41066836)
Tsx’s only reset-in-console mode is <Enter>, which makes it impossible to develop cli apps in watch mode.

You cannot run tsx from a non-project cwd if you’re using tsconfig/paths.

And personally I find its maintainers relatively unpleasant to message with. Leaves “you’re plebs” aftertaste most of the times.