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
Fix destructuring with holes in assign pattern #14240
Conversation
- fix `const` assign pattern - optimize the output of `let`/`var` assign pattern
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.
I think we should fix the issue in pushUnpackedArrayPattern
, so we can handle other patterns:
const [...x] = [,];
const [...{0: x}] = [,];
It seems Babel has handled it well. const [...x] = [,];
const [...{ 0: y }] = [,]; const x = [,];
const y = [,][0]; |
Could you check if |
I tested it locally. It behaves as same as the REPL. const x; It is indeed a bug related to this Pull Request. But I don't have a clear idea about how to fix it. For the test case like following const [ x = 1 ] = [,]; I am sure that But for const x = void 0; Meanwhile we will get var x = void 0; The What do you think about it? @JLHwung |
looks good to me. As a transpiler we should support valid language usage. The example above could be further transpiled into |
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.
Thanks!
Sorry, not finished. |
I think it's ready now. |
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.
Thanks!
hole
in assign pattern* refactor: extract destructuring transform routines * improve destructuring plugin typings * refactor: replace Record<string, boolean> to set * review comments * apply #14240 fix * fix: Babel should not crash when destructring arrray hole * make node 8 happy * refactor: extract buildObjectExcludingKeys
const
assign patternlet
/var
assign pattern