Node.js Runs TypeScript Now: Field Notes on Native Type Stripping
Headline: Node.js executes TypeScript files directly — node script.ts works with no loader, no ts-node, and no build step — by stripping type annotations at load time. Type stripping is on by default since Node.js 23.6 and ships in the 22.18 LTS release, but it only covers erasable syntax: I enforce that with TypeScript 5.8's erasableSyntaxOnly flag, moved type checking to tsc --noEmit in CI, and left my decorator-heavy NestJS services on their existing build. Key takeaways Node.js runs .ts files natively by replacing type annotations with whitespace, a mechanism called type stripping. It is enabled by default since Node.js 23.6 and in the 22.18 LTS release; on Node 22.6–22.17 it sits behind --experimental-strip-types . Type stripping handles only erasable syntax. enum , namespace with runtime code, and constructor parameter properties need the separate --experimental-transform-types flag. Node.js never type-checks and never reads tsconfig.json . The type checker is still tsc --noEmit , run in CI or a pre-commit hook. TypeScript 5.8's erasableSyntaxOnly compiler option turns every non-erasable construct into a compile error, which guarantees a file Node.js can run. Relative imports must spell out the .ts extension, and Node.js refuses to strip types inside node_modules — published packages still ship JavaScript. Can Node.js run TypeScript without a build step? Yes, for most application code. Node.js 22.6 introduced type stripping behind the --experimental-strip-types flag, Node.js 23.6 turned it on by default, and the 22.18 release brought the default-on behavior to the LTS line. On Node.js 24 — the current LTS and my daily runtime — node script.ts simply executes. // hello.ts const greet = ( name : string ): string => `Hello, ${ name } ` ; console . log ( greet ( ' Node 24 ' )); console . log ( process . features . typescript ); // 'strip' The mechanism matters. In strip mode Node.js replaces every type annotation with whitespace instead of compiling the file, so l