Skip to content

add grouped-and-auto-accessors#255

Merged
nzakas merged 4 commits intoestree:masterfrom
JLHwung:grouped-and-auto-accessors
Nov 10, 2025
Merged

add grouped-and-auto-accessors#255
nzakas merged 4 commits intoestree:masterfrom
JLHwung:grouped-and-auto-accessors

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Sep 9, 2021

View Rendered Text

This PR adds support to the Grouped Accessors and Auto-Accessors proposal.

```js
interface GetAccessorMethod <: Node {
type: "GetAccessorMethod";
params: [];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The params must be an empty array. It is to provide compatibility for general function AST visitors: A function always has params property.

}
```

### GetAccessorStub
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why use “stub” instead of using the proposal language, such as GetAutoAccessor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The "stub" comes from the proposed syntax section.

According to the spec, an auto-accessor is a simplified version of grouped accessor, e.g. accessor x = { get; set; }, where the accessor stub refers to the set and get shorthand.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah ok.

Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
interface ClassAccessor <: PropertyDefinition {
type: "ClassAccessor";
get: GetAccessorStub | GetAccessorMethod | null;
set: SetAccessorStub | SetAccessorMethod | null;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ClassAccessor should also have a value field which is similar to a class field's value/initializer:

accessor foo { get; set; } = 123;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ah, I see, it inherits these properties. I think this makes sense.

@JLHwung JLHwung force-pushed the grouped-and-auto-accessors branch from 66d4fd4 to 5ccc7c3 Compare September 19, 2021 21:12
computed: boolean;
get: GetAccessorStub | GetAccessorMethod | null;
set: SetAccessorStub | SetAccessorMethod | null;
}
Copy link
Copy Markdown
Contributor Author

@JLHwung JLHwung Sep 19, 2021

Choose a reason for hiding this comment

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

In the latest commit I removed the inheritance from Property, because it will inherit value: Expression and kind: "init" | "set" | "get". These properties are not applicable to the grouped accessor.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense.

@JLHwung JLHwung force-pushed the grouped-and-auto-accessors branch from 5ccc7c3 to c138d66 Compare September 19, 2021 21:14
@nzakas nzakas merged commit 50ee3a9 into estree:master Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants