Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5eb2bd0

Browse filesBrowse files
author
Andy Hanson
committed
findAllReferences: In export default foo, symbol name is foo
1 parent 50e2912 commit 5eb2bd0
Copy full SHA for 5eb2bd0

3 files changed

+25-4Lines changed: 25 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/utilities.ts‎

Copy file name to clipboardExpand all lines: src/compiler/utilities.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4032,6 +4032,10 @@ namespace ts {
40324032
return node.kind === SyntaxKind.ExportSpecifier;
40334033
}
40344034

4035+
export function isExportAssignment(node: Node): node is ExportAssignment {
4036+
return node.kind === SyntaxKind.ExportAssignment;
4037+
}
4038+
40354039
export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration {
40364040
return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration;
40374041
}
Collapse file

‎src/services/importTracker.ts‎

Copy file name to clipboardExpand all lines: src/services/importTracker.ts
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,17 +526,18 @@ namespace ts.FindAllReferences {
526526
return isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol, exportKind } : undefined;
527527
}
528528

529-
function symbolName(symbol: Symbol): string {
529+
function symbolName(symbol: Symbol): string | undefined {
530530
if (symbol.name !== "default") {
531531
return symbol.name;
532532
}
533533

534-
const name = forEach(symbol.declarations, decl => {
534+
return forEach(symbol.declarations, decl => {
535+
if (isExportAssignment(decl)) {
536+
return isIdentifier(decl.expression) ? decl.expression.text : undefined;
537+
}
535538
const name = getNameOfDeclaration(decl);
536539
return name && name.kind === SyntaxKind.Identifier && name.text;
537540
});
538-
Debug.assert(!!name);
539-
return name;
540541
}
541542

542543
/** If at an export specifier, go to the symbol it refers to. */
Collapse file
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: /a.ts
4+
////const [|{| "isWriteAccess": true, "isDefinition": true |}a|] = 0;
5+
////export default [|a|];
6+
7+
// @Filename: /b.ts
8+
////import [|{| "isWriteAccess": true, "isDefinition": true |}a|] from "./a";
9+
////[|a|];
10+
11+
const [r0, r1, r2, r3] = test.ranges();
12+
verify.referenceGroups([r0, r1], [
13+
{ definition: "const a: 0", ranges: [r0, r1] },
14+
{ definition: "import a", ranges: [r2, r3] }
15+
]);
16+
verify.singleReferenceGroup("import a", [r2, r3]);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.