Live data from Hacker News

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

nodejs.org

201–210 of 275 posts

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

#201

Earlier quoted context omitted.

This. It's 2025 and the node ecosystem is finally usable by default! ESM modules just work with both Node and Typescript, Node can run .ts files, and there's the a good enough test runner built in. --watch. The better built in packages - `node:fs/promises` - are nice with top-level await for easier async loops. It took a while to convince everyone involved to just be pragmatic, but it's nice now.

You mean TypeScript. TypeScript is finally usable by default.

I mean Node. I find writing Node in JS intolerable.

ESM, --watch, and TS syntax support is the combo that makes it all good!

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

#202

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…

> why not use Bun

I dislike being on the bleeding edge for things. NodeJS is the most supported in the JS ecosystem. I find it much better to just be on the "default" option for things. You know, choose boring technology.

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

#203

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…

Compile the packages to JavaScript before publishing. We absolutely should but be publishing TypeScript to npm.

As an additional compat dist? Maybe. Otherwise, just leave TS as-is. It simplifies debugging and would allow things like static Hermes to work.

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

#204

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…

I'm using Bun, but I avoid using any Bun.* function, because I don't want to bind my typescript project to a runtime.

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

#205

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…

> why not use Bun and forget about node?

Because Node is controlled by and maintained via the OpenJS Foundation. Bun is a venture-backed startup. That would be fine, but multiple, direct requests from me to the founder (Jared) about what the business model is (what I personally need to say "yes" or "no") have gone without response every time.

That led me to the assumption that Bun may very well be technically superior (or at least on the track to being so), but I can't bet anything significant or long-term on it. I need to know that this isn't just an exit vehicle for the founder (masquerading as a desire to fix JS server runtimes). Silence to a simple (dare I say, obvious) question doesn't bode well.

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

#208
post #144

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!

The benefit is one fewer step between Intellisense-enhanced development (which speeds things up with autocompletion and catches a lot of issues at design time already) and running the code, same as any linter.

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

#209
post #207

Its worth being clear that it isn't capable of actually executing TypeScript; it executes the "non-emitting" subset of the TypeScript language. If your app uses `enum`, among a couple other features, it wont work.

supposedly you can use --experimental-transform-types to enable enums but i never tried it so idk if does const enums correctly

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

#210

Earlier quoted context omitted.

But... that's like half the reason why I wanted this feature... Writing a library in TypeScript (with typechecks in CI/CD as devDependencies) and just importing it directly from Node.js...

It was the first thing I tried and of course it didn't work. It might finally be time to switch to Deno or Bun =(

> It might finally be time to switch to Deno or Bun =(

Bun has been great.

Deno... perhaps the less said, the better.

Post reply on HN