Add parse support for the "structs" proposal (only non-shared)#17624
Add parse support for the "structs" proposal (only non-shared)#17624JLHwung wants to merge 4 commits intobabel:mainfrom
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/60773 |
|
commit: |
7ecda07 to
7f6e64d
Compare
7f6e64d to
c377764
Compare
c377764 to
41753c2
Compare
| @@ -0,0 +1,4 @@ | |||
| @f | |||
| struct S {} | |||
There was a problem hiding this comment.
Agree with disallowing this but allowing accessors
There was a problem hiding this comment.
Right, and the member decorators are not allowed as well.
IMO accessors are essentially syntax sugar serving for the purpose of decorating otherwise accessor pairs once. They can be decoupled from decorators so I see no reason to ban them in non-shared structs.
|
@JLHwung could you rebase? |
41753c2 to
49299be
Compare
Rebased. Given that this PR only implements the non-shared part of the proposal, I think it'd be better shipped as Babel 8 only, otherwise Babel 7 will come with an incomplete proposal, plus we have not yet implemented the transform part. WDYT about the AST shape? Currently the member within the struct body is still class members. Do you think it is better stay with class members or rename all |
|
I agree that this only applies to releases in Babel 8. |
Here is the ESTree proposal: https://github.com/estree/estree/blob/master/experimental/structs.md ESTree reuses class members because their names do not contain the |
|
Maybe let's just wait for 8.1, targeting end of march then? So we don't need to rush this.
Do we have transforms that just look for the |
This PR adds support of the non-shared structs with the following AST design:
The member within the struct body is still class members. I have not yet decided whether we should leave it as-is or rename them from
Class*toStruct*.