Fix bug in preset-env usage plugin with destructure in for-of (#6662)
This commit is contained in:
parent
9ae23639ad
commit
287b485d0e
@ -217,14 +217,12 @@ export default function({ types: t }: { types: Object }): Plugin {
|
|||||||
const obj = node.init;
|
const obj = node.init;
|
||||||
|
|
||||||
if (!t.isObjectPattern(node.id)) return;
|
if (!t.isObjectPattern(node.id)) return;
|
||||||
const props = node.id.properties;
|
|
||||||
|
|
||||||
if (!t.isReferenced(obj, node)) return;
|
if (!t.isReferenced(obj, node)) return;
|
||||||
|
|
||||||
// doesn't reference the global
|
// doesn't reference the global
|
||||||
if (path.scope.getBindingIdentifier(obj.name)) return;
|
if (obj && path.scope.getBindingIdentifier(obj.name)) return;
|
||||||
|
|
||||||
for (let prop of props) {
|
for (let prop of node.id.properties) {
|
||||||
prop = prop.key;
|
prop = prop.key;
|
||||||
if (
|
if (
|
||||||
!node.computed &&
|
!node.computed &&
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
for (const { padStart } of foo) {
|
||||||
|
console.log('b'.padEnd(5));
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
import "@babel/polyfill/lib/core-js/modules/es7.string.pad-end";
|
||||||
|
import "@babel/polyfill/lib/core-js/modules/es7.string.pad-start";
|
||||||
|
|
||||||
|
for (const {
|
||||||
|
padStart
|
||||||
|
} of foo) {
|
||||||
|
console.log('b'.padEnd(5));
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
["../../../../lib", {
|
||||||
|
"targets": {
|
||||||
|
"node": "7"
|
||||||
|
},
|
||||||
|
"useBuiltIns": "usage",
|
||||||
|
"modules": false
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
for (const { a } of foo) {
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
for (const {
|
||||||
|
a
|
||||||
|
} of foo) {
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
["../../../../lib", {
|
||||||
|
"targets": {
|
||||||
|
"node": "8"
|
||||||
|
},
|
||||||
|
"useBuiltIns": "usage",
|
||||||
|
"modules": false
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user