Skip to content

Commit 31ec5e7

Browse files
author
Andy
authored
findAllReferences: Don't fail on broken re-export (#21841)
1 parent aa1ebda commit 31ec5e7

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/services/findAllReferences.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,8 @@ namespace ts.FindAllReferences.Core {
914914

915915
// At `export { x } from "foo"`, also search for the imported symbol `"foo".x`.
916916
if (search.comingFrom !== ImportExport.Export && exportDeclaration.moduleSpecifier && !propertyName) {
917-
searchForImportedSymbol(state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier), state);
917+
const imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
918+
if (imported) searchForImportedSymbol(imported, state);
918919
}
919920

920921
function addRef() {
@@ -923,7 +924,7 @@ namespace ts.FindAllReferences.Core {
923924
}
924925

925926
function getLocalSymbolForExportSpecifier(referenceLocation: Identifier, referenceSymbol: Symbol, exportSpecifier: ExportSpecifier, checker: TypeChecker): Symbol {
926-
return isExportSpecifierAlias(referenceLocation, exportSpecifier) ? checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) : referenceSymbol;
927+
return isExportSpecifierAlias(referenceLocation, exportSpecifier) && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) || referenceSymbol;
927928
}
928929

929930
function isExportSpecifierAlias(referenceLocation: Identifier, exportSpecifier: ExportSpecifier): boolean {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: /a.ts
4+
////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] };
5+
6+
verify.singleReferenceGroup("import x");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: /a.ts
4+
////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "nonsense";
5+
6+
verify.singleReferenceGroup("import x");

0 commit comments

Comments
 (0)