findAllReferences: In export default foo, symbol name is foo

This commit is contained in:
Andy Hanson
2017-05-15 08:24:29 -07:00
parent 50e2912cd2
commit 5eb2bd08ac
3 changed files with 25 additions and 4 deletions

View File

@@ -526,17 +526,18 @@ namespace ts.FindAllReferences {
return isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol, exportKind } : undefined;
}
function symbolName(symbol: Symbol): string {
function symbolName(symbol: Symbol): string | undefined {
if (symbol.name !== "default") {
return symbol.name;
}
const name = forEach(symbol.declarations, decl => {
return forEach(symbol.declarations, decl => {
if (isExportAssignment(decl)) {
return isIdentifier(decl.expression) ? decl.expression.text : undefined;
}
const name = getNameOfDeclaration(decl);
return name && name.kind === SyntaxKind.Identifier && name.text;
});
Debug.assert(!!name);
return name;
}
/** If at an export specifier, go to the symbol it refers to. */