Skip to content

Commit

Permalink
Document decorators 2022-03 version.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Sep 5, 2022
1 parent 08c1cb0 commit 0284112
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ You should enable these features only if you are using an older version.
export @dec class C {}
```

- `allowCallParenthesized` (`boolean`, defaults to `true`)

When `false`, disallow decorators in the `@(...)()` form in favor of `@(...())`. The stage 3 decorators proposal uses `allowCallParenthesized: false`.

- `pipelineOperator`:

- `proposal` (required, accepted values: `minimal`, `fsharp`, `hack`, ~~`smart`~~ (deprecated))
Expand Down
17 changes: 9 additions & 8 deletions docs/plugin-proposal-decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,20 @@ require("@babel/core").transformSync("code", {

### `version`

`"2021-12"`, `"2018-09"` or `"legacy"`. Defaults to `"2018-09"`.
`"2022-03"`, `"2021-12"`, `"2018-09"` or `"legacy"`. Defaults to `"2018-09"`.

Selects the decorators proposal to use:
- `"2022-03"` is the proposal version that reached consensus for Stage 3 in the March 2022 TC39 meeting. You can read more about it at [`tc39/proposal-decorators@8ca65c046d`](https://github.com/tc39/proposal-decorators/tree/8ca65c046dd5e9aa3846a1fe5df343a6f7efd9f8).
- `"2021-12"` is the proposal version as it was presented to TC39 in Dec 2021. You can read more about it at [`tc39/proposal-decorators@d6c056fa06`](https://github.com/tc39/proposal-decorators/tree/d6c056fa061646178c34f361bad33d583316dc85).
- `"2018-09"` is the proposal version that was initially promoted to Stage 2 presented to TC39 in Sept 2018. You can read more about it at [`tc39/proposal-decorators@7fa580b40f`](https://github.com/tc39/proposal-decorators/tree/7fa580b40f2c19c561511ea2c978e307ae689a1b).
- `legacy` is the original Stage 1 proposal, defined at [`wycats/javascript-decorators@e1bf8d41bf`](https://github.com/wycats/javascript-decorators/blob/e1bf8d41bfa2591d949dd3bbf013514c8904b913/README.md).

> ⚠️ If you specify the `decoratorsBeforeExport` option, `version` defaults to `"2018-09"`.
### `decoratorsBeforeExport`

This option:
- is disallowed when using `version: "legacy"`;
- is disallowed when using `version: "legacy"` or `version: "2021-12"`;
- is required when using `version: "2018-09"`;
- is optional and defaults to `false` when using `version: "2021-12"`.

Expand All @@ -114,9 +117,7 @@ export @decorator class Bar {}
export class Foo {}
```

This option was added to help tc39 collect feedback from the community by allowing experimentation with both possible syntaxes.

For more information, check out: [tc39/proposal-decorators#69](https://github.com/tc39/proposal-decorators/issues/69).
This option was added to help tc39 collect feedback from the community by allowing experimentation with both possible syntaxes. The proposal now settled on having decorators after `export`.

### `legacy`

Expand All @@ -128,15 +129,15 @@ Use the legacy (stage 1) decorators syntax and behavior.

#### NOTE: Compatibility with `@babel/plugin-proposal-class-properties`

If you are including your plugins manually and using `@babel/plugin-proposal-class-properties`, make sure that `@babel/plugin-proposal-decorators` comes _before_ `@babel/plugin-proposal-class-properties`.
If you are including your plugins manually and using `@babel/plugin-proposal-class-properties` and legacy decorators, make sure that `@babel/plugin-proposal-decorators` comes _before_ `@babel/plugin-proposal-class-properties`.

Wrong:

```json
{
"plugins": [
"@babel/plugin-proposal-class-properties",
["@babel/plugin-proposal-decorators", { "legacy": true }]
["@babel/plugin-proposal-decorators", { "version": "legacy" }]
]
}
```
Expand All @@ -146,7 +147,7 @@ Right:
```json
{
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-decorators", { "version": "legacy" }],
"@babel/plugin-proposal-class-properties"
]
}
Expand Down

0 comments on commit 0284112

Please sign in to comment.