update
This commit is contained in:
+18
-7
@@ -50,13 +50,9 @@ var _default = (0, _helperPluginUtils.declare)(api => {
|
||||
node
|
||||
} = func;
|
||||
|
||||
if (!node.id) {
|
||||
if (func.isMethod()) {
|
||||
path.replaceWith(scope.buildUndefinedNode());
|
||||
return;
|
||||
}
|
||||
|
||||
node.id = scope.generateUidIdentifier("target");
|
||||
if (_core.types.isMethod(node)) {
|
||||
path.replaceWith(scope.buildUndefinedNode());
|
||||
return;
|
||||
}
|
||||
|
||||
const constructor = _core.types.memberExpression(_core.types.thisExpression(), _core.types.identifier("constructor"));
|
||||
@@ -66,6 +62,21 @@ var _default = (0, _helperPluginUtils.declare)(api => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!node.id) {
|
||||
node.id = scope.generateUidIdentifier("target");
|
||||
} else {
|
||||
let scope = path.scope;
|
||||
const name = node.id.name;
|
||||
|
||||
while (scope !== func.parentPath.scope) {
|
||||
if (scope.hasOwnBinding(name) && !scope.bindingIdentifierEquals(name, node.id)) {
|
||||
scope.rename(name);
|
||||
}
|
||||
|
||||
scope = scope.parent;
|
||||
}
|
||||
}
|
||||
|
||||
path.replaceWith(_core.types.conditionalExpression(_core.types.binaryExpression("instanceof", _core.types.thisExpression(), _core.types.cloneNode(node.id)), constructor, scope.buildUndefinedNode()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user