-
Notifications
You must be signed in to change notification settings - Fork 358
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
add grouped-and-auto-accessors #255
base: master
Are you sure you want to change the base?
Conversation
```js | ||
interface GetAccessorMethod <: Node { | ||
type: "GetAccessorMethod"; | ||
params: []; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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.
66d4fd4
to
5ccc7c3
Compare
computed: boolean; | ||
get: GetAccessorStub | GetAccessorMethod | null; | ||
set: SetAccessorStub | SetAccessorMethod | null; | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
5ccc7c3
to
c138d66
Compare
View Rendered Text
This PR adds support to the Grouped Accessors and Auto-Accessors proposal.