From 9c2b95dae3378f2b41abfee7fde9e8d1ecc6aeee Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 16 Feb 2018 14:49:23 -0800 Subject: [PATCH] Make FAR handle non-existent imported symbols --- src/services/findAllReferences.ts | 2 +- tests/cases/fourslash/findAllRefsBadImport.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/findAllRefsBadImport.ts diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index b1e6909f093..bc36ef06226 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -356,7 +356,7 @@ namespace ts.FindAllReferences.Core { /** Core find-all-references algorithm for a normal symbol. */ function getReferencedSymbolsForSymbol(symbol: Symbol, node: Node, sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken, options: Options): SymbolAndEntries[] { - symbol = skipPastExportOrImportSpecifierOrUnion(symbol, node, checker); + symbol = skipPastExportOrImportSpecifierOrUnion(symbol, node, checker) || symbol; // Compute the meaning from the location and the symbol it references const searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), symbol.declarations); diff --git a/tests/cases/fourslash/findAllRefsBadImport.ts b/tests/cases/fourslash/findAllRefsBadImport.ts new file mode 100644 index 00000000000..89a81d81f79 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsBadImport.ts @@ -0,0 +1,7 @@ +/// + +////import { [|ab|] as [|cd|] } from "doesNotExist"; + +const [r0, r1] = test.ranges(); +verify.referencesOf(r0, [r1]); +verify.referencesOf(r1, [r1]);