---
title: "tsx doesn’t support decorators"
description: "tsx runs on esbuild, which doesn't support TypeScript decorators. Why NestJS still breaks with emitDecoratorMetadata in tsconfig, and how ts-node solved it."
canonical: https://omiid.me/notebook/42/tsx-doesn-t-support-decorators
author: Omid Sayfun
published: 2025-03-26
updated: 2026-08-09
---

# tsx doesn’t support decorators

[tsx](https://github.com/privatenumber/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](https://www.typescriptlang.org/docs/handbook/decorators.html), 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.

```json
{
	"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](https://github.com/privatenumber/tsx/issues/347) 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:

```shell
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.
