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
Parenthesize non-simple decorator expression #14378
Parenthesize non-simple decorator expression #14378
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51538/ |
|
||
@(this.foo)(bar) method3() {} |
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.
Added a new parser test case here.
{ | ||
"plugins": [["decorators", { "decoratorsBeforeExport": false }]], | ||
"decoratorsBeforeExport": true, | ||
"parserOpts": { "createParenthesizedExpressions": true } |
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.
We should also add a parser test with "createParenthesizedExpressions": true
Whops, I approved after reviewing only the generator changes
@babel/generator
generates incorrect code@this[bar]
from@(this[bar])
In this PR we ensure that
@babel/generator
generates correct codes for non-simple decorator expressions such as@(this.foo().bar)
. In the first commit we mark all these non-simple expressions as "parenthesized", so that we generate correct AST for cases like@(this).bar
. The second commit fixes the generator issue.The current decorator spec ("2022-03") share the same decorator expression grammar production with "2021-12" and "2018-09".