Your team runs several TypeScript services on Node.js 24: would you ship them through built-in type stripping, a runner such as tsx, or a compiled build, and why?
answer
- what syntax the code uses
- type checking is always separate
- startup cost versus build pipeline
- what Node 26 removes
basics
~20 sNo single answer: built-in type stripping suits services written in erasable syntax, a compiled build suits code needing decorators, enums or tsconfig features and libraries, and a full-syntax runner mainly fits development. Every option still needs a separate type-check step.
solid answer
~40 sI would decide per service on three axes. **Syntax**: Node.js 24 strips only erasable syntax, so code that uses decorators, enums, parameter properties or `tsconfig.json` `paths` needs a compiler or a full-syntax runner such as tsx, which registers through `--import`. **Operations**: a compiled build ships plain JavaScript, needs `--enable-source-maps` for readable stacks and adds no per-start transform; stripping removes the build and keeps exact line numbers, but transforms every file at each start; a runner adds a devDependency to the runtime image. **Durability**: stripping is stable since v24.12.0, while `--experimental-transform-types` is a release candidate in 24 and removed in 26, so it is not a production foundation. Whichever path wins, `tsc --noEmit` stays a CI gate, and shared libraries ship JavaScript because Node refuses TypeScript under `node_modules`.
go deeper
Recall the three ways to run TypeScript on Node 24 and that none of them checks types at run time.
Explain what each option accepts and costs: erasable-only stripping, a runner through --import, a build with source maps.
Identify which services in a fleet cannot strip, and why shared libraries must be published as JavaScript.
Set the team default and its exceptions on syntax, start-time cost and LTS durability, and plan for what Node 26 removes.
## The decision a lead actually owns Node.js 24 gives a team three credible ways to run TypeScript services, and they differ in what code they accept, what they cost on every start, and how they age across LTS upgrades. None of them type-checks at run time. The choice is a team default with exceptions, not a single right answer. ## The three options | | Built-in type stripping | Full-syntax runner (for example tsx) | Compiled build | |---|---|---|---| | How it starts | `node server.ts` | `node --import=tsx server.ts` or the runner's own command | `node --enable-source-maps dist/server.js` | | Syntax accepted | erasable syntax only | full TypeScript, reads `tsconfig.json` | everything the compiler accepts | | Work at each start | strip every `.ts` file loaded | transpile through loader hooks | none beyond loading JavaScript | | Stack trace lines | exact, no map needed | depends on the runner's maps | need maps and `--enable-source-maps` | | Runtime dependencies | none | the runner package | none | | Type checking | separate `tsc --noEmit` | separate (tsx does not check types) | the compiler can check during the build | ## Axis 1: what the code is allowed to contain Stripping accepts only syntax that can be deleted: no `enum`, no parameter properties, no namespaces with runtime code, no `import x = require()`, no decorators, no `tsconfig.json` `paths`, no `.tsx`. A codebase built around a decorator-based framework, or one that leans heavily on enums, is not a stripping candidate without a rewrite. A newer service written to the compiler's `erasableSyntaxOnly` option is. Make the constraint explicit in the compiler settings, so a violation fails in the editor and CI instead of at startup. ## Axis 2: what it costs to run - **Startup.** Stripping and runtime transpiling do work on every process start, for every file. That matters most where replicas start often, such as autoscaling or short-lived jobs. The module compile cache can keep stripped output and V8 code cache on disk across runs, but a build moves the work out of the start path entirely. - **Artifact contents.** A built image holds JavaScript and maps; a stripped one holds sources; a runner-based one also carries the runner and its own dependencies in production. - **Error locations.** Stripping keeps exact positions for free. A build needs maps shipped with the output and `--enable-source-maps`, which adds latency whenever `Error.stack` is read. ## Axis 3: how each option ages 1. Type stripping is **stable** from v24.12.0; the stable flag spelling is `--no-strip-types`. 2. `--experimental-transform-types`, which would accept enums and parameter properties, is a **release candidate** in 24, and the Node 26 documentation records it as **removed** in v26.0.0. Building production on it guarantees work at the next LTS. 3. Loader hooks are moving too: `module.register()` is documentation-deprecated in 24.15.0 and runtime-deprecated in 26, with `module.registerHooks()` as the replacement. Anything that runs TypeScript through customization hooks, your own or a runner's, depends on an API surface that is still moving. ## Constraints that apply whichever way you choose - **Libraries ship JavaScript.** Node refuses to strip files under `node_modules`, so a shared internal package must be published compiled even if every service consuming it strips its own sources. - **Type checking is its own gate.** `tsc --noEmit` (or the build itself) has to run in CI; no execution path proves types. - **Imports name real files.** Under stripping, relative specifiers carry `.ts`; the compiler's import-extension rewriting option helps when the same sources are also built. ## A defensible default - Use built-in stripping for services and scripts whose code fits erasable syntax, with `tsc --noEmit` in CI. - Use a compiled build for libraries, for services that need decorators, enums or older JavaScript targets, and wherever start-time work matters. - Use a full-syntax runner for local development and tooling where the build loop is the bottleneck, not as the production entry point. - Revisit at each LTS upgrade, reading the TypeScript page's history block for what changed. A principal answer states which axis dominates for *this* fleet, names the exceptions, and plans the next LTS.
- A service on built-in type stripping must adopt a library pattern that relies on decorators. What changes in your plan?Node 24 does not transform decorators, even with `--experimental-transform-types`, because they are a TC39 Stage 3 proposal, so that service leaves the stripping path. Move it to a compiled build (or a full-syntax runner in development only), ship maps with `--enable-source-maps`, and keep the other erasable services as they are rather than switching the whole fleet.
- What would you put in CI so a stripped service never discovers a syntax problem at startup in production?Run `tsc --noEmit` with the compiler set to reject non-erasable syntax and to require explicit type-only imports, plus a smoke start of the service with `node` on its entry file. The compiler sees every file, so it catches enums, parameter properties and value-imported types even on lazily imported paths; the smoke start catches what the loader rejects in the static graph, such as TypeScript loaded from `node_modules`.
- Built-in type stripping makes a separate type-check step unnecessary.
- --experimental-transform-types is a safe production default on Node 24.
- A shared internal library can ship raw .ts for services to strip.
- A runner such as tsx type-checks the code as it loads it.
- Compiled output needs no flag to show .ts lines in stack traces.
Assumes Node.js 24: type stripping is stable since v24.12.0, --experimental-transform-types is a release candidate there and is removed in Node 26.