How to Run TypeScript Directly in Node.js with Erasable Syntax
Install Node.js 23.6+ (or 22.6+ with --experimental-strip-types ) and TypeScript 5.8+.
Add "erasableSyntaxOnly": true and "verbatimModuleSyntax": true to your tsconfig.json compiler options.
Set "module": "nodenext" and "noEmit": true in tsconfig.json .
Replace all enum declarations with as const objects and derived union types.
Convert constructor parameter properties to explicit property declarations and assignments.
Refactor value-bearing namespace blocks into standard ES module exports.
Run your TypeScript files directly with node src/server.ts — no build step required.
Verify type safety by running tsc --noEmit in CI, since Node.js strips types without checking them.
TypeScript 5.8 introduced the --erasableSyntaxOnly compiler flag, which validates whether TypeScript code contains only type constructs that can be stripped away without altering runtime behavior.…