Consider default params for object pattern.

This commit is contained in:
Artem Yavorsky 2017-03-18 16:26:22 +02:00
parent b608e28aa7
commit 45b41740d8
4 changed files with 11 additions and 2 deletions

View File

@ -310,8 +310,11 @@ export default function () {
} else if (id.isObjectPattern()) {
for (let i = 0; i < id.node.properties.length; i++) {
const prop = id.node.properties[i];
let propValue = prop.value;
if (!t.isRestProperty(prop)) {
const propValue = prop.value;
if (t.isAssignmentPattern(propValue)) {
propValue = propValue.left;
}
addTo(exports, propValue.name, propValue);
exportsToInsert.push(buildExportsAssignment(propValue, propValue));
nonHoistedExportNames[propValue.name] = true;

View File

@ -0,0 +1,5 @@
"use strict";
const { foo, bar = 1 } = {};
exports.foo = foo;
exports.bar = bar;

View File

@ -1,5 +1,5 @@
"use strict";
const { foo: bar, baz } = {};
exports.baz = baz;
exports.bar = bar;
exports.baz = baz;