mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-07 08:45:19 -05:00
findAllReferences: In export default foo, symbol name is foo
This commit is contained in:
@@ -4032,6 +4032,10 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.ExportSpecifier;
|
||||
}
|
||||
|
||||
export function isExportAssignment(node: Node): node is ExportAssignment {
|
||||
return node.kind === SyntaxKind.ExportAssignment;
|
||||
}
|
||||
|
||||
export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration {
|
||||
return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration;
|
||||
}
|
||||
|
||||
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user