Back to Tsx

Native TypeScript type stripping

notes/node/type-stripping.md

4.23.63.3 KB
Original Source

Native TypeScript type stripping

Node's built-in TypeScript execution pipeline and its runtime limits.

Timeline

ChangePR or issueVerified releases
--experimental-transform-typesnodejs/node#54283v22.7.0, v23.0.0
module.stripTypeScriptTypes()#55282, nodejs/node#54300v22.13.0, v23.2.0
TypeScript in --eval and STDIN#56359v22.14.0, v23.6.0, v24.0.0
Default strip-only execution#56350, nodejs/typescript#17v22.18.0, v23.6.0, v24.0.0
Stable status#60600v24.12.0, v25.2.0
Remove transform mode#61803v26.0.0

Runtime pipeline

Public API and loader path

node:module exposes stripTypeScriptTypes(), but it differs from the loader path.

AspectPublic APIInternal loader
node_modulesNo restrictionThrows ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING (v24.15.0 typescript.js#L180-L183)
Compile cacheNot usedKeyed by filename (v24.15.0 typescript.js#L198)
ModeStrip or transform through v25Strip only in v26 (v26.4.0 typescript.js#L101)

Runtime limits