From 369f419272df313fbb9fe43d547b40980fab002f Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 7 Jul 2020 16:13:07 -0700 Subject: [PATCH] Fixes searches for symbols exported using export * as Fixes #39006 --- src/services/importTracker.ts | 4 ++++ .../cases/fourslash/findAllRefsReExportStarAs.ts | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/cases/fourslash/findAllRefsReExportStarAs.ts diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 5396459584da5..6fa447b17f671 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -122,6 +122,10 @@ namespace ts.FindAllReferences { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } + else if (direct.exportClause.kind === SyntaxKind.NamespaceExport) { + // `export * as foo from "foo"` add to indirect uses + addIndirectUsers(getSourceFileLikeForImportDeclaration(direct)); + } else { // This is `export { foo } from "foo"` and creates an alias symbol, so recursive search will get handle re-exports. directImports.push(direct); diff --git a/tests/cases/fourslash/findAllRefsReExportStarAs.ts b/tests/cases/fourslash/findAllRefsReExportStarAs.ts new file mode 100644 index 0000000000000..3f2c63e9767a4 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsReExportStarAs.ts @@ -0,0 +1,16 @@ +/// + +// @Filename: /leafModule.ts +////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}hello|] = () => 'Hello';|] + +// @Filename: /exporting.ts +////export * as Leaf from './leafModule'; + +// @Filename: /importing.ts +//// import { Leaf } from './exporting'; +//// Leaf.[|hello|]() + +verify.noErrors(); +const ranges = test.ranges(); +const [r0Def, r0, r1] = ranges; +verify.singleReferenceGroup("const hello: () => string", [r0, r1]); \ No newline at end of file