notes/node/type-stripping.md
Node's built-in TypeScript execution pipeline and its runtime limits.
| Change | PR or issue | Verified releases |
|---|---|---|
--experimental-strip-types | nodejs/node#53725 | v22.6.0, v23.0.0 |
--experimental-transform-types | nodejs/node#54283 | v22.7.0, v23.0.0 |
module.stripTypeScriptTypes() | #55282, nodejs/node#54300 | v22.13.0, v23.2.0 |
TypeScript in --eval and STDIN | #56359 | v22.14.0, v23.6.0, v24.0.0 |
| Default strip-only execution | #56350, nodejs/typescript#17 | v22.18.0, v23.6.0, v24.0.0 |
| Stable status | #60600 | v24.12.0, v25.2.0 |
| Remove transform mode | #61803 | v26.0.0 |
amaro.transformSync is loaded in v24.0.0 typescript.js#L47-L48, and processTypeScriptCode owns the internal flow (typescript.js#L144)..ts to TypeScript formats according to package type and syntax detection (v24.0.0 get_format.js#L133-L149).loader.js#L1684-L1686).loader.js#L503-L512); TypeScript translators then strip that source before delegating to the ordinary module/CommonJS translator (v24.15.0 translators.js#L627-L642).node:module exposes stripTypeScriptTypes(), but it differs from the loader path.
| Aspect | Public API | Internal loader |
|---|---|---|
node_modules | No path restriction (v24.15.0 typescript.js#L102-L127) | Throws ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING (v24.15.0 typescript.js#L180-L183) |
| Compile cache | Not used (public path) | Keyed by filename (v24.15.0 typescript.js#L198) |
| Transform mode | Public mode: "transform" available through v25 (v25 API); removed in v26 (v26 API) | Loader mode followed the runtime flag through v25 (v25 loader); transform mode was removed in v26 (release) |
Strip mode replaces erasable syntax with whitespace, preserving source length and line/column offsets; sourceUrl appends a sourceURL comment, while sourceMap: true is invalid in strip mode (v24 tests, v26 tests). Direct loader execution therefore reports original locations without generated source maps (stack test).
The public helper permits caught fallback and accepts an arbitrary sourceUrl; the internal loader strips only after format selection and cannot return to an earlier user hook when syntax is unsupported (ESM translator, CJS loader).
tsconfig.json; paths and downleveling are unsupported (v26.0.0 typescript.md#L80-L88).typescript.md#L128-L136)..tsx, non-erasable syntax, and TypeScript in node_modules remain unsupported (v26.0.0 typescript.md#L128-L217).import Alias = Namespace.Member require JavaScript generation and fail strip-only execution with ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX (v26.5.1 typescript.md#L140-L162)..mts, .cts, and .ts; extensionless entrypoints receive JavaScript package formats instead (loader).