# Source: https://rsbuild.dev/config/source/decorators.md

# source.decorators

* **Type:**

```ts
type Decorators = {
  version?: 'legacy' | '2022-03';
};
```

Used to configure the decorators syntax.

## decorators.version

* **Type:** `'legacy' | '2022-03'`
* **Default:** `'2022-03'`

Specify the decorator syntax version to be used.

If you want to know the differences between different decorators versions, you can refer to: [How does this proposal compare to other versions of decorators?](https://github.com/tc39/proposal-decorators?tab=readme-ov-file#how-does-this-proposal-compare-to-other-versions-of-decorators)

### 2022-03

`2022-03` corresponds to the Stage 3 decorator proposal, equivalent to the decorator syntax supported by TypeScript 5.0 by default.

```ts title="rsbuild.config.ts"
export default {
  source: {
    decorators: {
      version: '2022-03',
    },
  },
};
```

Reference documentation:

* [JavaScript meta programming with the 2022-03 decorators API](https://2ality.com/2022/10/javascript-decorators.html)
* [TypeScript 5.0 Decorators](https://typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#decorators)

### legacy

Equivalent to TypeScript's `experimentalDecorators: true`.

```ts title="rsbuild.config.ts"
export default {
  source: {
    decorators: {
      version: 'legacy',
    },
  },
};
```

Reference documentation:

* [A Complete Guide to TypeScript Decorators](https://mirone.me/a-complete-guide-to-typescript-decorator/)
* [TypeScript Decorators](https://typescriptlang.org/docs/handbook/decorators.html)