Fix multi-file usage

1. Follow aliases with getSupers.
2. Make fix in file with superclass, not with the error.
This commit is contained in:
Nathan Shively-Sanders
2020-05-22 09:06:05 -07:00
parent 82d9576d9b
commit e466bb94c1
3 changed files with 34 additions and 2 deletions

View File

@@ -47,6 +47,7 @@ namespace ts.codefix {
startPosition = baseProp.valueDeclaration.pos;
endPosition = baseProp.valueDeclaration.end;
file = getSourceFileOfNode(baseProp.valueDeclaration);
}
else {
Debug.fail("fixPropertyOverrideAccessor codefix got unexpected error code " + code);

View File

@@ -229,8 +229,11 @@ namespace ts.codefix {
while (decl) {
const superElement = getClassExtendsHeritageElement(decl);
const superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression);
const superDecl = superSymbol && find(superSymbol.declarations, isClassLike);
if (superDecl) { res.push(superDecl); }
if (!superSymbol) break;
const symbol = superSymbol.flags & SymbolFlags.Alias ? checker.getAliasedSymbol(superSymbol) : superSymbol;
const superDecl = find(symbol.declarations, isClassLike);
if (!superDecl) break;
res.push(superDecl);
decl = superDecl;
}
return res;