TypeScript in Node.js: Strengths, Limits, and the Future
summary
Node.js v22+ runs .ts files without transpilation but it only strips types, it does not type‑check; runtime uses the Amaro pipeline built on SWC for fast type‑stripping, so stack traces align and no source maps are needed. Limitations: packages in node_modules must still ship JavaScript, node never enforces types, enums/namespaces/decorators/parameter properties aren’t erasable, and import type + allowImportingTsExtensions / module: nodeNext / noEmit are required for a sane workflow. Use tsc or ESLint autofixes to keep code erasable.
AI-written summary · about
chapters (18)
- 0:00Introduction
- 1:19What is TypeScript
- 3:29Running TypeScript in Node.js
- 4:54Node.js TypeScript support
- 7:25TypeScript in Node modules
- 8:08Type checking in Node.js
- 9:11TypeScript config for Node
- 10:59TS extensions and ESM
- 13:30ESM vs CommonJS in TypeScript
- 14:55Type stripping vs transformations
- 18:31How type stripping works
- 20:17Ensuring erasable syntax
- 21:21Replacing enums and namespaces
- 23:07Type imports and decorators
- 25:37The future of enums
- 27:44Why choose type stripping
- 28:50Future of TypeScript and JavaScript
- 30:16Conclusion
