Skip to content

Commit 8341b13

Browse files
authored
Merge pull request #22004 from amcasey/FARBadImport
Make FAR handle non-existent imported symbols
2 parents f95b9bc + b64eefd commit 8341b13

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/services/findAllReferences.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ namespace ts.FindAllReferences.Core {
356356

357357
/** Core find-all-references algorithm for a normal symbol. */
358358
function getReferencedSymbolsForSymbol(symbol: Symbol, node: Node, sourceFiles: ReadonlyArray<SourceFile>, checker: TypeChecker, cancellationToken: CancellationToken, options: Options): SymbolAndEntries[] {
359-
symbol = skipPastExportOrImportSpecifierOrUnion(symbol, node, checker);
359+
symbol = skipPastExportOrImportSpecifierOrUnion(symbol, node, checker) || symbol;
360360

361361
// Compute the meaning from the location and the symbol it references
362362
const searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), symbol.declarations);
@@ -405,7 +405,7 @@ namespace ts.FindAllReferences.Core {
405405
}
406406

407407
/** Handle a few special cases relating to export/import specifiers. */
408-
function skipPastExportOrImportSpecifierOrUnion(symbol: Symbol, node: Node, checker: TypeChecker): Symbol {
408+
function skipPastExportOrImportSpecifierOrUnion(symbol: Symbol, node: Node, checker: TypeChecker): Symbol | undefined {
409409
const { parent } = node;
410410
if (isExportSpecifier(parent)) {
411411
return getLocalSymbolForExportSpecifier(node as Identifier, symbol, parent, checker);
@@ -425,7 +425,7 @@ namespace ts.FindAllReferences.Core {
425425
return isTypeLiteralNode(decl.parent) && isUnionTypeNode(decl.parent.parent)
426426
? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name)
427427
: undefined;
428-
}) || symbol;
428+
});
429429
}
430430

431431
/**
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////import { [|ab|] as [|cd|] } from "doesNotExist";
4+
5+
const [r0, r1] = test.ranges();
6+
verify.referencesOf(r0, [r1]);
7+
verify.referencesOf(r1, [r1]);

0 commit comments

Comments
 (0)