Skip to content

Commit

Permalink
Merge pull request #6052 from babel/array-destructuring-hole
Browse files Browse the repository at this point in the history
Array destructuring hole
  • Loading branch information
hzoo committed Aug 4, 2017
2 parents 8c457e9 + 0e58007 commit 30c4d6b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
Expand Up @@ -119,6 +119,8 @@ export default function() {
}
} else if (left.isArrayPattern()) {
for (const element of left.node.elements) {
if (!element) continue;

const name = element.name;

const exports = this.exports[name];
Expand Down
Expand Up @@ -12,3 +12,7 @@ export function f2 () {
export function f3 () {
[x, y, z] = [3, 4, 5]
}

export function f4 () {
[x, , y] = [3, 4, 5]
}
Expand Up @@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
exports.f1 = f1;
exports.f2 = f2;
exports.f3 = f3;
exports.f4 = f4;
let x = exports.x = 0;
let y = exports.y = 0;

Expand Down Expand Up @@ -35,3 +36,9 @@ function f3() {
exports.y = y;
exports.x = x;
}

function f4() {
[x,, y] = [3, 4, 5];
exports.y = y;
exports.x = x;
}
@@ -0,0 +1 @@
var arr = [ 'a',, 'b', ...c ];
@@ -0,0 +1 @@
var arr = ['a',, 'b'].concat(babelHelpers.toConsumableArray(c));

0 comments on commit 30c4d6b

Please sign in to comment.