News for hackers. Stuff that matters.
Re:Node.js adds experimental support for TypeScript by rockwotj on Wednesday July 24, 2024 @11:57PM (#41064573)
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 after a few months.

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.

Re:Node.js adds experimental support for TypeScript by yamumsahoe on Thursday July 25, 2024 @12:04AM (#41064596)
correction: the only deno future that i want
Re:Node.js adds experimental support for TypeScript by sholladay on Thursday July 25, 2024 @01:18AM (#41064956)
Deno has so many other great features. Most web standard APIs are available in Deno, for example. It can do URL imports. It has a built in linter, formatter, and test framework. Built in documentation generator. A much better built in web server.

Node is copying many of these features to varying degrees of success. But Deno is evolving, too.

Re:Node.js adds experimental support for TypeScript by throwitaway1123 on Thursday July 25, 2024 @02:14AM (#41065248)
Node supports URL imports via the --experimental-network-imports command line option. There's also a built in test runner now.
Re:Node.js adds experimental support for TypeScript by johnny22 on Thursday July 25, 2024 @01:54AM (#41065135)
the url imports is one the things I don't want.
Re:Node.js adds experimental support for TypeScript by niklasmtj on Thursday July 25, 2024 @02:13AM (#41065241)
There are also the `npm:`, `node:` and `jsr:` specifiers now. So you don't have to use the URL imports if you don't feel them.
Re:Node.js adds experimental support for TypeScript by sholladay on Thursday July 25, 2024 @11:21AM (#41069743)
You want to be forced to use a centralized registry? I don’t know. URL imports also enable fully isomorphic modules. I think you would enjoy the freedom of URL imports if the ergonomics were better. For example, it should just default to https:// so you don’t have to type that. Import maps also help a lot with this, definitely use them. But they could be even better by having first-class support for templating the module version into the URL so that the version can be stored separately, alongside the module name. Popular hosts with well-known URL structures could have their URLs automatically templated so you only have to specify the host and not the rest of the URL.

In other words, the tooling could be better, but the fundamentals of URL imports are sound, IMO.

Re:Node.js adds experimental support for TypeScript by zzo38computer on Thursday July 25, 2024 @12:51PM (#41070772)
I disagree. It should not default to "https://" (I think defaulting to local files would be better).

Furthermore, I think that it should be made so that the "hashed:" scheme that I had invented (in the Scorpion protocol/file-format specification document, although this scheme can be used independently of that) can also be usable.

And, popular hosts with well-known URL structures automatically templating also I would disagree, although it might do to allow any expressions in place of the string literals and then add functions for abbreviations of some of those URLs, if that would help (although I still think it is unnecessary).

Re:Node.js adds experimental support for TypeScript by johnny22 on Friday August 02, 2024 @04:20AM (#41137043)
yes, I would prefer to use a centralized registry indeed. However, that's not actually what i'm talking about here. Even just decoupling the import from the package is enough. You can already do this by by pointing a package in package.json to a remote tarball or git repo.
Re:Node.js adds experimental support for TypeScript by WuxiFingerHold on Thursday July 25, 2024 @07:03AM (#41067140)
... and obviously the only one you know.

Kidding aside: You should really take an hour and check out the manual and std lib (https://jsr.io/@std). I was surprised how far Deno has come. A lot of pretty useful stuff you would otherwise need tons of NPM modules for.

Re:Node.js adds experimental support for TypeScript by medv on Thursday July 25, 2024 @05:03AM (#41066457)
Re:Node.js adds experimental support for TypeScript by tnzk on Thursday July 25, 2024 @06:23AM (#41066880)
This seems very interesting approach to scripting. Does it basically provides with an alias to child_process.exec as $ and besides that I can write in the same way I'd do in Node?

> Node.js standard library requires additional hassle before using

I read the hassle as having to setup Node runtime in advance, but zx requires npm to install so I'm not sure.