diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts
index 8b9937394f10b..ad243d59d890f 100644
--- a/src/services/findAllReferences.ts
+++ b/src/services/findAllReferences.ts
@@ -914,7 +914,8 @@ namespace ts.FindAllReferences.Core {
// At `export { x } from "foo"`, also search for the imported symbol `"foo".x`.
if (search.comingFrom !== ImportExport.Export && exportDeclaration.moduleSpecifier && !propertyName) {
- searchForImportedSymbol(state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier), state);
+ const imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier);
+ if (imported) searchForImportedSymbol(imported, state);
}
function addRef() {
@@ -923,7 +924,7 @@ namespace ts.FindAllReferences.Core {
}
function getLocalSymbolForExportSpecifier(referenceLocation: Identifier, referenceSymbol: Symbol, exportSpecifier: ExportSpecifier, checker: TypeChecker): Symbol {
- return isExportSpecifierAlias(referenceLocation, exportSpecifier) ? checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) : referenceSymbol;
+ return isExportSpecifierAlias(referenceLocation, exportSpecifier) && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) || referenceSymbol;
}
function isExportSpecifierAlias(referenceLocation: Identifier, exportSpecifier: ExportSpecifier): boolean {
diff --git a/tests/cases/fourslash/findAllRefsReExport_broken.ts b/tests/cases/fourslash/findAllRefsReExport_broken.ts
new file mode 100644
index 0000000000000..7c42d9e2b6cdc
--- /dev/null
+++ b/tests/cases/fourslash/findAllRefsReExport_broken.ts
@@ -0,0 +1,6 @@
+///
+
+// @Filename: /a.ts
+////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] };
+
+verify.singleReferenceGroup("import x");
diff --git a/tests/cases/fourslash/findAllRefsReExport_broken2.ts b/tests/cases/fourslash/findAllRefsReExport_broken2.ts
new file mode 100644
index 0000000000000..4f8a3ea5f4524
--- /dev/null
+++ b/tests/cases/fourslash/findAllRefsReExport_broken2.ts
@@ -0,0 +1,6 @@
+///
+
+// @Filename: /a.ts
+////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "nonsense";
+
+verify.singleReferenceGroup("import x");