Update param scope values when expanding parameters.
This commit is contained in:
@@ -15,8 +15,13 @@ export default function() {
|
||||
path.arrowFunctionToExpression();
|
||||
}
|
||||
|
||||
convertFunctionRest(path);
|
||||
convertFunctionParams(path);
|
||||
const convertedRest = convertFunctionRest(path);
|
||||
const convertedParams = convertFunctionParams(path);
|
||||
|
||||
if (convertedRest || convertedParams) {
|
||||
// Manually reprocess this scope to ensure that the moved params are updated.
|
||||
path.scope.crawl();
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -96,7 +96,7 @@ export default function convertFunctionParams(path) {
|
||||
}
|
||||
}
|
||||
|
||||
if (body.length === 0) return;
|
||||
if (body.length === 0) return false;
|
||||
|
||||
// we need to cut off all trailing parameters
|
||||
if (firstOptionalIndex !== null) {
|
||||
@@ -112,4 +112,6 @@ export default function convertFunctionParams(path) {
|
||||
} else {
|
||||
path.get("body").unshiftContainer("body", body);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ function optimiseLengthGetter(path, argsId, offset) {
|
||||
|
||||
export default function convertFunctionRest(path) {
|
||||
const { node, scope } = path;
|
||||
if (!hasRest(node)) return;
|
||||
if (!hasRest(node)) return false;
|
||||
|
||||
const rest = node.params.pop().argument;
|
||||
|
||||
@@ -273,7 +273,7 @@ export default function convertFunctionRest(path) {
|
||||
path.replaceWith(argsId);
|
||||
}
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
state.references = state.references.concat(
|
||||
@@ -338,4 +338,6 @@ export default function convertFunctionRest(path) {
|
||||
|
||||
target.insertBefore(loop);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user