Skip to content

Commit 6b5c448

Browse files
authored
Merge pull request #14131 from Microsoft/release-2.2_default_import_name
Handle undefined import name
2 parents 125a8fa + ee13f31 commit 6b5c448

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/services/findAllReferences.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ namespace ts.FindAllReferences {
154154
const importDecl = importSpecifier.parent as ts.ImportDeclaration;
155155
Debug.assert(importDecl.moduleSpecifier === importSpecifier);
156156
const defaultName = importDecl.importClause.name;
157-
const defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName));
157+
const defaultReferencedSymbol = defaultName && checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName));
158158
if (symbol === defaultReferencedSymbol) {
159159
return defaultName.text;
160160
}

tests/cases/fourslash/findAllRefsForDefaultExport.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
////import [|{| "isWriteAccess": true, "isDefinition": true |}g|] from "./a";
88
/////*ref*/[|g|]();
99

10+
// @Filename: c.ts
11+
////import { f } from "./a";
12+
1013
verify.singleReferenceGroup("function f(): void");
1114
verify.goToDefinition("ref", "def");

0 commit comments

Comments
 (0)