close

source.decorators

  • Type:
type Decorators = {
  version?: 'legacy' | '2022-03' | '2023-11';
};

Used to configure the decorators syntax.

decorators.version

  • Type: 'legacy' | '2022-03' | '2023-11'
  • 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?

2023-11

2023-11 corresponds to the November 2023 version of the Stage 3 decorator proposal.

rsbuild.config.ts
export default {
  source: {
    decorators: {
      version: '2023-11',
    },
  },
};

References: tc39/proposal-decorators, @babel/plugin-proposal-decorators.

2022-03

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

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

References: JavaScript meta programming with the 2022-03 decorators API, TypeScript 5.0 Decorators.

legacy

Equivalent to TypeScript's experimentalDecorators: true.

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

References: A Complete Guide to TypeScript Decorators, TypeScript Decorators.