46 comments

[ 0.23 ms ] story [ 68.0 ms ] thread
It looks like this works by stripping away the type information, so at best it saves you a transpilation pass and doesn't improve safety.
I agree, that said if the main reason people use TypeScript is security they should use a decent programming language instead.
Impressed with what Node is doing the last years, deno and bun has really made Node focus and improve. It was stuck for a while
They added type striping, not full TS support.

And the biggest issue with Node IMO is that the standard lib still forces you to rely on endless npm dependencies.

Node is still very much stuck.

> the standard lib still forces you to rely on endless npm dependencies

How? We have async/await file access, a async/await test runner, and even async/await sleep built in. What are you missing?

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?
Deno has sandboxing and much more - use it instead
Bun can do it for years now. I think it's time to move on.
Great, it does type stripping by replacing TypeScript with whitespace. Can it also now load ES5 modules? That way we can use them for everything.
I think this + node:test makes Node.js a pretty compelling sensible default for most things now. Running things with `tsx` was such a QoL improvement when it happened, but it didn't solve everything.

Runtime type assertion at the edges is mostly solved through `zod` and tools like `ts-rest` and `trpc` makes it so much easier to do full-stack Typescript these days.

i switched to python a while ago. it has batteries included. i feel so much better now that i dont have to debug all the quirks of a half-baked system.
But still, bun is the winner here. I recently started using bun and now not moving to node.js again. It just works.
Node still has a better repl, but I do agree. Bun is really good. It’s my goto, too.
Yup, I'm in the same boat. Been using Bun for a year or so, and enjoying the many quality of life improvements. I still use Node when the project requires it, but I'm actively moving them over to Bun when I can. Still it's great to see Node continues to improve in its own way, benefiting a wider audience.
I wish browsers also supported directly running typescript files.
Contrary to the popular trend, I usually stick with Node and NPM for most of my projects. That said, I’ve run into plenty of headaches with CommonJS vs ESM quirks. Sharing code between frontend and backend (via shared libraries) still feels messy because of those differences. In one project I actually had to switch to Bun as the runtime, since Node kept failing at runtime, and strangely enough, Bun just worked without issues.
Even though this should be the way to go, it still leaves a bitter taste.

Remember ESM fiasco? Now we have a few years of that all over again, this time with different versions of TypeScript, settings, and tsgo. Good news!

This is for transpilation only. it does not actually validate the typescript or perform any checks during runtime.

esm actually caused errors so there should not be any issues here

does it support watch mode? does it support path aliases?
It supports the same things JS scripts can do because it's merely stripping type annotations.
What backend framework is the go to these days? Still Express?
Express is still popular, but a lot projects these days use a full-stack framework like Next.js, SvelteKit, etc.

Fastify, NestJS (bleh), Koa, Hono are the modern replacements for express, none of them have caught on as a standard though. My personal favorite for small projects is Polka (https://github.com/lukeed/polka), when I'm not using Go instead.

IMHO the only reason you are using JS in the backend is because of some meta framework, otherwise is not worth. So at least for Nuxt is nitro, not sure for SvelteKit or the other React meta frameworks.
Next is where it's at these days in my opinion. You get a full-featured client-side React framework (the only one that supports modern React SSG), and then on top of it you get a better-organized approach to doing everything you can do with Express.

And do mean everything: I run an entire Postrgraphile server through Next (and you can easily do the sme with Supabase or a similar tool)!

(comment deleted)
I’m not a heavy JS/TS dev so here’s an honest question: why not use Bun and forget about node? Sure I understand that not every project is evergreen but isn’t Bun a much runtime in general? It supports TS execution from day 1, has much faster dependency resolution, better ergonomics… and I could keep going.

I know I’m just a single data point but I’ve had a lot of success migrating old node projects to bun (in fact I haven’t used node itself since Bun was made public)

Again, I might be saying something terribly stupid because JS/TS isn’t really my turf so please let me know if I’m missing something.

It's not able to execute TypeScript, but a subset of it. The claim in the title is misleading if not totally wrong.

This will unfortunately drive people towards using TS only as a linter, and not use its powerful features that are inherently impossible to implement with just type stripping.

The best thing is that they are shipping this as "type stripping" which means that there are no sourcemaps involved, making it zero-cost in production!

Very well done Node team!

I've tried it, still doesn't work as well as Bun's Typescript and test execution capabilities. So basically just went back to Bun.
the js ecosystem is so sad.

all threads saying the truth, js on the server could implement actual ts and not yet another transpiler gets downvoted.

js "experts" think they are smarter because they know ts is just annotations for a linter. they don't even question why that is so and why that sucks.

This is great up until you get to the fact that typescript will not be accepted under node_modules [0].

That leads me to ask, what about project dependencies? I wrote a lib for my data models in typescript and I want to import that into my app in node, in typescript? Does the rule only apply to npm packages? There’s opportunity here…

I wrote a runtime in golang that runs typescript (well, JavaScript in general). The grafana folks have sobek that all they need is to add type striping. I feel like if there’s one runtime where typescript could be adopted fully and it would change the world is Node.js. No transpiler, no typescript-go, no rust (well, maybe some rust ;) just a great parser that will keep track of the source map and types in debug mode (for tracing).

Either way, kudos to the node team, contributors, for pulling in the goal posts to make the kick to launch shorter. I’m still a fan of bun, and my own runtime, but node is the standard by which we all are kinda following. I also like that the embedding api is simple and clean to use now so if you want to make an executable, you can.

[0] https://nodejs.org/api/typescript.html#type-stripping-in-dep...

I’m curious what the benefit of stuff like this is vs tsc --watch and running the JS?

I’ve always just run tsc to a .gitignored’d directory and execute my JS from there.

Edit: Thanks for the responses. There’s some great examples in there!