tsx doesn’t support decorators

March 26, 2025 · Updated on August 09, 2026

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.ts

made 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.