mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 02:45:24 -05:00
fix(38815): dive in arrow functions to check only this usage instead of checking all statements (#38865)
This commit is contained in:
@@ -405,6 +405,20 @@ namespace ts.refactor.extractSymbol {
|
||||
rangeFacts |= RangeFacts.UsesThis;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ArrowFunction:
|
||||
// check if arrow function uses this
|
||||
forEachChild(node, function check(n) {
|
||||
if (isThis(n)) {
|
||||
rangeFacts |= RangeFacts.UsesThis;
|
||||
}
|
||||
else if (isClassLike(n) || (isFunctionLike(n) && !isArrowFunction(n))) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
forEachChild(n, check);
|
||||
}
|
||||
});
|
||||
// falls through
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
if (isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) {
|
||||
@@ -418,7 +432,7 @@ namespace ts.refactor.extractSymbol {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
// do not dive into functions (except arrow functions) or classes
|
||||
// do not dive into functions or classes
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user