Skip to content

Commit

Permalink
fix: should not remove let binding even it is wrapped in closure
Browse files Browse the repository at this point in the history
Fixes #10339
  • Loading branch information
JLHwung committed Aug 15, 2019
1 parent eb3767d commit 1f95f2e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
4 changes: 1 addition & 3 deletions packages/babel-plugin-transform-block-scoping/src/index.js
Expand Up @@ -453,9 +453,7 @@ class BlockScoping {
if (binding.kind === "let" || binding.kind === "const") {
binding.kind = "var";

if (wrappedInClosure) {
scope.removeBinding(ref.name);
} else {
if (!wrappedInClosure) {
scope.moveBindingTo(ref.name, parentScope);
}
}
Expand Down
@@ -0,0 +1,4 @@
for (const {foo, ...bar} of {}) {
() => foo;
bar;
}
@@ -0,0 +1,3 @@
{
"plugins": ["transform-block-scoping", ["proposal-object-rest-spread", { "loose": true }]]
}
@@ -0,0 +1,16 @@
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var _loop = function (foo, bar) {
() => foo;

bar;
};

for (var _ref of {}) {
var {
foo
} = _ref,
bar = _objectWithoutPropertiesLoose(_ref, ["foo"]);

_loop(foo, bar);
}

0 comments on commit 1f95f2e

Please sign in to comment.