Merge pull request #18931 from amcasey/ExtractConstantThis

Allow Extract Constant into enclosing scope in spite of RangeFacts.UsesThis
This commit is contained in:
Andrew Casey
2017-10-12 11:25:00 -07:00
committed by GitHub
8 changed files with 133 additions and 3 deletions

View File

@@ -476,7 +476,10 @@ namespace ts.refactor.extractSymbol {
// if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class
const containingClass = getContainingClass(current);
if (containingClass) {
return [containingClass];
const containingFunction = findAncestor(current, isFunctionLikeDeclaration);
return containingFunction
? [containingFunction, containingClass]
: [containingClass];
}
}