Type stripping is Node.js's built-in way to run TypeScript. Node.js removes erasable TypeScript syntax (type annotations, interfaces, and similar), replaces it with whitespace, and executes the remaining JavaScript. It does not type-check your code and it does not transform TypeScript features that need new JavaScript to be generated.
This page is a high-level overview. For a short runbook, see Running TypeScript Natively. For the detailed specification, see the TypeScript API docs.
TypeScript adds types on top of JavaScript. Much of that syntax is erasable: it exists only for the type checker and editors. Type stripping deletes that erasable syntax at runtime so node can run .ts / .mts / .cts files without a separate build step.
function greet(name: string): string { return `Hello, ${name}`; } console.log(greet('Node'));
node greet.ts
Node.js ignores tsconfig.json when stripping types. Features that depend on tsconfig settings (path aliases, downlevel emit, and similar) are intentionally unsupported. Prefer a TypeScript runner or transpilation when you need those.
On Node.js v22.18.0+ (and current release lines where type stripping is enabled by default), run a file that uses only erasable syntax:
node example.ts
Disable the feature when you need to:
node --no-strip-types example.ts
Module systems follow the same rules as JavaScript:
.tsfollows the nearestpackage.json"type"field (like.js).mtsis always an ES module.ctsis always CommonJS.tsxis not supported
Import specifiers still need file extensions: import './file.ts'.
| Support | Versions (summary) |
|---|---|
| Enabled by default | v22.18.0+, v23.6.0+, and current release lines that ship type stripping on by default |
| Marked stable | See the History table in the API docs (for example v24.12.0 / v25.2.0) |
Always check the docs for the exact line you run in production. Older minor versions may still require an experimental flag.
No. Use the TypeScript compiler (or your editor) for that:
npx tsc --noEmit
A common workflow is: run with node for fast feedback, and run tsc --noEmit in CI.
Supported examples include type annotations, interfaces, type aliases, and import type / inline type imports.
Not supported by type stripping alone (these need transform / a runner / tsc emit), including:
enumdeclarations- parameter properties
- namespaces that contain runtime values
- import aliases
- experimental decorators (until they exist in JavaScript)
Publishing packages as raw TypeScript under node_modules is also refused — Node.js will not strip types inside dependency trees.
Match Node.js's erasable-syntax model with TypeScript 5.8+ (5.7+ is a common minimum in older guides):
{ "compilerOptions": { "target": "esnext", "module": "nodenext", "rewriteRelativeImportExtensions": true, "erasableSyntaxOnly": true, "verbatimModuleSyntax": true } }
Add "noEmit": true when you only execute .ts files and do not emit .js output.