Consider rest params for array pattern in exports.
This commit is contained in:
parent
06f67e1ad3
commit
b608e28aa7
@ -321,9 +321,10 @@ export default function () {
|
||||
for (let i = 0; i < id.node.elements.length; i++) {
|
||||
let elem = id.node.elements[i];
|
||||
if (!elem) continue;
|
||||
if (!t.isRestElement(elem)) {
|
||||
if (t.isAssignmentPattern(elem)) {
|
||||
elem = elem.left;
|
||||
} else if (t.isRestElement(elem)) {
|
||||
elem = elem.argument;
|
||||
}
|
||||
const name = elem.name;
|
||||
addTo(exports, name, elem);
|
||||
@ -331,7 +332,6 @@ export default function () {
|
||||
nonHoistedExportNames[name] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
path.insertAfter(exportsToInsert);
|
||||
}
|
||||
path.replaceWith(declaration.node);
|
||||
|
||||
@ -0,0 +1 @@
|
||||
export const [foo, bar = 2] = [];
|
||||
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
const [foo, bar = 2] = [];
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
@ -0,0 +1 @@
|
||||
export const [foo, bar, ...baz] = [];
|
||||
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const [foo, bar, ...baz] = [];
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
exports.bar = baz;
|
||||
@ -1 +1 @@
|
||||
export const [foo, bar = 2] = [1];
|
||||
export const [foo, bar] = [];
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
const [foo, bar = 2] = [1];
|
||||
const [foo, bar] = [];
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user