Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align decorators to 2021-12 spec #273

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 31 additions & 5 deletions experimental/decorators.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [Decorators](https://github.com/wycats/javascript-decorators)
# [Decorators](https://github.com/tc39/proposal-decorators)

## Decorator

Expand All @@ -9,18 +9,44 @@ interface Decorator <: Node {
}
```

## Used
## AccessorProperty
```js
interface AccessorProperty <: Node {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On AccessorProperty, an alternative design is to add accessor: boolean to PropertyDefinition. Babel introduced a new type so that we can support https://github.com/tc39/proposal-grouped-and-auto-accessors based on the new AST node type. See also discussions here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a new node type makes sense. 👍

type: "AccessorProperty";
key: Expression | PrivateIdentifier;
value: Expression | null;
computed: boolean;
static: boolean;
decorators: [ Decorator ];
}
```

## Class
```js
extend interface MethodDefinition {
extend interface Class {
decorators: [ Decorator ];
}
```

## ClassBody

```js
extend interface ClassBody {
body: [ MethodDefinition | PropertyDefinition | StaticBlock | AccessorProperty ];
}
```

extend interface Property {
## MethodDefinition
```js
extend interface MethodDefinition {
decorators: [ Decorator ];
}
```

extend interface Class {
## PropertyDefinition

```js
extend interface PropertyDefinition {
decorators: [ Decorator ];
}
```