scope.rename() missing identifier in VariableDeclarator (#11595)

This commit is contained in:
任文龙 2020-05-26 16:05:12 -05:00 committed by GitHub
parent 0ca5f8b2ec
commit 429840dc2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 1 deletions

View File

@ -20,7 +20,8 @@ const renameVisitor = {
} }
}, },
"AssignmentExpression|Declaration"(path, state) { "AssignmentExpression|Declaration|VariableDeclarator"(path, state) {
if (path.isVariableDeclaration()) return;
const ids = path.getOuterBindingIdentifiers(); const ids = path.getOuterBindingIdentifiers();
for (const name in ids) { for (const name in ids) {

View File

@ -0,0 +1,7 @@
function c(b) {
var a = b + 1,
a = a + 1,
a = a + 1;
return a;
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["./plugin"]
}

View File

@ -0,0 +1,7 @@
function c(b) {
var _a = b + 1,
_a = _a + 1,
_a = _a + 1;
return _a;
}

View File

@ -0,0 +1,9 @@
module.exports = function() {
return {
visitor: {
Scope(path) {
path.scope.rename("a", "_a");
}
}
};
}