BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Node.js 23.6 Now Runs TypeScript Natively

Node.js 23.6 Now Runs TypeScript Natively

Log in to listen to this article

The Node team recently announced shipping TypeScript native support in Node 23.6. Node developers can now run TypeScript files without any extra configuration or flags. The feature, which was experimental in Node 22.6, is now stable. Native TypeScript support was among the most requested Node features by developers.

Node developers can now create an index.ts file, run node index.ts without additional flags, and Node will remove the TypeScript type annotations from the file and run the resulting JavaScript code.

Caveats apply. Node.js ignores tsconfig.json files and therefore features that depend on settings within tsconfig.json, such as paths or converting newer JavaScript syntax to older standards (e.g., decorators, a stage 3 proposal), are intentionally unsupported. Similarly, there is no support for JSX files.

Node also does not support TypeScript syntaxes that require JavaScript code generation. As Node will simply replace inline types with whitespaces (i.e., type stripping), developers can run TypeScript code without needing source maps. However, some TypeScript constructs, which have runtime semantics or require JavaScript code generation, will not be supported. The set of supported TypeScript syntax is dubbed erasable syntax. The latest release of TypeScript (i.e.,, TypeScript 5.8) adds a --erasableSyntaxOnly flag to support this workflow.

The Node.js documentation lists the most important unsupported syntax:

The most prominent features that require transformation are:

  • Enum declarations
  • namespace with runtime code
  • legacy module with runtime code
  • parameter properties
  • import aliases

Native TypeScript support brings Node closer to alternative TypeScript-native runtimes such as Deno or Bun. The Deno team detailed in a blog post the additional features still offered only by Deno, among which tsconfig support and distributing TypeScript without transpilation.

Developers are encouraged to review the extensive discussion of the feature roadmap, which includes the rationale behind the choice of tradeoffs made by the team and the feedback from developers.

About the Author

BT