Earlier quoted context omitted.
What are the recent improvements in node itself? Last actually note-worthy improvement I heard of was properly supporting import/export (although do you still need to use the .mjs hack?), but I've been out of the loop here for sometime so would be nice to know what they've added since.
> (although do you still need to use the .mjs hack?) Syntax detection is enabled by default in v22.7.0, v20.19.0: https://nodejs.org/api/packages.html#syntax-detection Sounds like the obvious correct solution, making .cjs and .mjs obsolete - unless of course someone uses import() statements exclusively, in which case I need to ask: why?
Node.js is able to execute TypeScript files without additional configuration
51–60 of 275 posts
Re: Node.js is able to execute TypeScript files without additional configuration
#52It looks like this works by stripping away the type information, so at best it saves you a transpilation pass and doesn't improve safety.
Re: Node.js is able to execute TypeScript files without additional configuration
#53Earlier quoted context omitted.
TypeScript never promised improving safety, maybe it’s a common misconception. But TypeScript has no runtime mode or information. You were always at the mercy of running and not ignoring the typechecker. Nothing stopped you from running ts-node or tsx on code with egregious type errors. TypeScript is more like a linter in that regard.
> TypeScript is more like a linter that's exactly the point--GP is pointing out that node can't do that part
Re: Node.js is able to execute TypeScript files without additional configuration
#54It looks like this works by stripping away the type information, so at best it saves you a transpilation pass and doesn't improve safety.
One of Typescript's design goals is that removing all type-related parts of the source text should yield a valid JavaScript file. A typescript compiler does not generate code (unlike, say, PureScript). You can run a typechecker (such as tsc) that check various properties of your code statically, relying on the type information. It is then erased. The same applies, say, to Python: type annotations are ignored at runti…
Just for generics, I believe
Re: Node.js is able to execute TypeScript files without additional configuration
#55I 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.
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.
Re: Node.js is able to execute TypeScript files without additional configuration
#56It looks like this works by stripping away the type information, so at best it saves you a transpilation pass and doesn't improve safety.
One of Typescript's design goals is that removing all type-related parts of the source text should yield a valid JavaScript file. A typescript compiler does not generate code (unlike, say, PureScript). You can run a typechecker (such as tsc) that check various properties of your code statically, relying on the type information. It is then erased. The same applies, say, to Python: type annotations are ignored at runti…
Re: Node.js is able to execute TypeScript files without additional configuration
#57Earlier 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.
does it have a go fmt / lint command yet?
Re: Node.js is able to execute TypeScript files without additional configuration
#58Re: Node.js is able to execute TypeScript files without additional configuration
#59I wish browsers also supported directly running typescript files.