Print parentheses around identifier let where necessary#13269
Print parentheses around identifier let where necessary#13269nicolo-ribaudo merged 3 commits intobabel:mainfrom
let where necessary#13269Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/45877/ |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 1aea906:
|
|
Ah, I just remembered that OptionalMemberExpression can also print a left bracket if I don't think this can occur in head position in a freshly-parsed AST, but it can occur if a transform rearranges nodes and also sets Adding the appropriate check is easy enough, but I'll need to write a non-fixture test to get coverage. |
|
Ideally we should add some validation to ensure that |
|
Thanks! |
If we detect that the identifier
letwould be printed in a location that forbids it (either unconditionally or when followed by[), print parentheses around the identifier so that it remains legal and correct.The forbidden locations are:
let [)let [)let [)let) (regular andawait)