tsx doesn’t support decorators
tsx runs TypeScript files with no config, which is why it became my default runner. It does not run TypeScript decorators. Yesterday I hit errors on a NestJS project, and it took me a while to realize the tsx runner was the problem.
NestJS relies heavily on decorators, which are still Stage 3 experimental. Two tsconfig.json options are required: experimentalDecorators to allow the syntax, and emitDecoratorMetadata so NestJS dependency injection can read constructor parameter types.
{
"compilerOptions": {
"target": "ES5",
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}With both options set, tsc attaches the metadata to functions, classes, and constructor parameters. tsx never calls tsc. It compiles with esbuild, and esbuild doesn’t support decorators out of the box, so you still get Parameter decorators only work when experimental decorators are enabled even though the option is already enabled. Extra plugins are needed to make it work. As of now, there’s an open issue for this, but no plans to address it. The constraint is esbuild, not TypeScript: SWC-based runners do compile TypeScript decorators once you enable them in .swcrc.
In my case, I was using tsx with nest-commander to run CLI commands. ts-node uses the TypeScript compiler directly, so it honours both tsconfig options. Switching to:
ts-node -r tsconfig-paths/register src/cli/main.tsmade everything work again.
tl;dr
TSX doesn't support TypeScript decorators due to its reliance on esbuild. To work around this, especially in NestJS projects, use ts-node instead.
Join My Newsletter
Occasional notes on software, tools, and things I learn. No spam.
Unsubscribe anytime.
Continue Reading
- Tuning Postgres and pgvector: the three knobs that matterAug 18, 2026
- Agent knowledge base rot: 14 symptoms, checks, and fixesAug 18, 2026
- Knowledge bases for AI agents: 14 ways they rotAug 17, 2026
- AI text watermarking: how it works and what it can't doAug 16, 2026
- HNSW vs IVFFlat: choosing and building your pgvector indexAug 14, 2026