Skip to content

Commit c73867d

Browse files
committed
docs: add Decorator Support
1 parent 4a50268 commit c73867d

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

docs/options/target.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,28 @@ You can also pass an array of targets to ensure compatibility across multiple en
7777
tsdown --target chrome100 --target node20.18
7878
```
7979

80+
### Decorator Support
81+
82+
There are currently two major implementations of decorators in the JavaScript ecosystem:
83+
84+
- **Stage 2 (Legacy) Decorators**: The older, experimental implementation, often referred to as "legacy decorators."
85+
- **Stage 3 Decorators**: The latest official proposal, which is significantly different from the legacy version.
86+
87+
If you are using **stage 2 (legacy) decorators**, make sure to enable the `experimentalDecorators` option in your `tsconfig.json`:
88+
89+
```json
90+
{
91+
"compilerOptions": {
92+
"experimentalDecorators": true
93+
}
94+
}
95+
```
96+
97+
If you need to use the **latest TC39 Stage 3 decorators**, please note that `tsdown` (and its underlying engines, Rolldown/Oxc) **do not currently support this feature**. For more information and updates on Stage 3 decorator support, see [this GitHub issue](https://github.com/oxc-project/oxc/issues/9170#issuecomment-3354571325).
98+
99+
> **Note:**
100+
> The two decorator implementations are very different. Make sure you are using the correct configuration and syntax for your chosen decorator version.
101+
80102
# CSS Targeting
81103

82104
`tsdown` can also downlevel CSS features to match your specified browser targets. For example, a CSS nesting `&` selector will be flattened if the target is `chrome108` or lower.

docs/zh-CN/options/target.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,28 @@ tsdown --target es2020
7777
tsdown --target chrome100 --target node20.18
7878
```
7979

80+
### 装饰器支持
81+
82+
目前在 JavaScript 生态中有两种主要的装饰器实现:
83+
84+
- **Stage 2(旧版)装饰器**:较早的实验性实现,通常被称为「legacy decorators」。
85+
- **Stage 3 装饰器**:最新的官方提案,与旧版实现有显著区别。
86+
87+
如果您使用的是**Stage 2(旧版)装饰器**,请确保在 `tsconfig.json` 中启用 `experimentalDecorators` 选项:
88+
89+
```json
90+
{
91+
"compilerOptions": {
92+
"experimentalDecorators": true
93+
}
94+
}
95+
```
96+
97+
如果您需要使用**最新的 TC39 Stage 3 装饰器**,请注意 `tsdown`(及其底层引擎 Rolldown/Oxc)**目前尚不支持此功能**。关于 Stage 3 装饰器支持的更多信息和最新进展,请参阅 [此 GitHub issue](https://github.com/oxc-project/oxc/issues/9170#issuecomment-3354571325)
98+
99+
> **注意:**
100+
> 两种装饰器实现差异很大,请确保您使用了正确的配置和语法以匹配所选的装饰器版本。
101+
80102
# CSS 目标
81103

82104
`tsdown` 也可以将 CSS 特性降级以匹配您指定的浏览器目标。例如,如果目标是 `chrome108` 或更低版本,CSS 嵌套的 `&` 选择器将被展开为平铺结构。

0 commit comments

Comments
 (0)