Fix destructuring with holes in assign pattern#14240
Fix destructuring with holes in assign pattern#14240nicolo-ribaudo merged 4 commits intobabel:mainfrom magic-akari:fix/issue-14239
Conversation
- fix `const` assign pattern - optimize the output of `let`/`var` assign pattern
JLHwung
left a comment
There was a problem hiding this comment.
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 |
Sorry, not finished. |
|
I think it's ready now. |
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
constassign patternlet/varassign pattern