diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index a8a809008ab38..000e7e2224a3b 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -132,6 +132,7 @@ namespace ts.FindAllReferences { return node.parent.parent; case SyntaxKind.ImportClause: + case SyntaxKind.NamespaceExport: return node.parent; case SyntaxKind.BinaryExpression: diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 6fa447b17f671..3d6064e07152c 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -481,6 +481,9 @@ namespace ts.FindAllReferences { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } + else if (isNamespaceExport(parent)) { + return exportInfo(symbol, ExportKind.Named); + } // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (isExportAssignment(parent)) { return getExportAssignmentExport(parent); diff --git a/tests/cases/fourslash/findAllRefsReExportStarAs.ts b/tests/cases/fourslash/findAllRefsReExportStarAs.ts index 3f2c63e9767a4..a0392048ea8bf 100644 --- a/tests/cases/fourslash/findAllRefsReExportStarAs.ts +++ b/tests/cases/fourslash/findAllRefsReExportStarAs.ts @@ -1,16 +1,20 @@ /// // @Filename: /leafModule.ts -////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}hello|] = () => 'Hello';|] +////[|{| "id": "helloDecl" |}export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "helloDecl" |}hello|] = () => 'Hello';|] // @Filename: /exporting.ts -////export * as Leaf from './leafModule'; +////[|{| "id": "leafExportDecl" |}export * as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "leafExportDecl" |}Leaf|] from './leafModule';|] // @Filename: /importing.ts -//// import { Leaf } from './exporting'; -//// Leaf.[|hello|]() +//// [|{| "id": "leafImportDecl" |}import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "leafImportDecl" |}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 +const [helloDecl, helloDef, leafExportDecl, leafDef, leafImportDecl, leafImportDef, leafUse, helloUse] = ranges; +verify.singleReferenceGroup("const hello: () => string", [helloDef, helloUse]); +const leafExportAsRef = { definition: "import Leaf", ranges: [leafDef] }; +const leafImportRef = { definition: "import Leaf", ranges: [leafImportDef, leafUse] }; +verify.referenceGroups([leafDef], [leafExportAsRef, leafImportRef]); +verify.referenceGroups([leafImportDef, leafUse], [leafImportRef, leafExportAsRef]); diff --git a/tests/cases/fourslash/referencesForStatementKeywords.ts b/tests/cases/fourslash/referencesForStatementKeywords.ts index e5a171f0d9f10..f089e9d100013 100644 --- a/tests/cases/fourslash/referencesForStatementKeywords.ts +++ b/tests/cases/fourslash/referencesForStatementKeywords.ts @@ -17,7 +17,7 @@ //// ////// export ... from ... ////[|{| "id": "exportDecl1" |}[|export|] [|type|] * [|from|] "[|{| "isWriteAccess": false, "isDefinition": false, "contextRangeId": "exportDecl1" |}./g|]";|] -////[|{| "id": "exportDecl2" |}[|export|] [|type|] [|{| "id": "exportDecl2_namespaceExport" |}* [|as|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "exportDecl2_namespaceExport" |}H|]|] [|from|] "[|{| "isWriteAccess": false, "isDefinition": false, "contextRangeId": "exportDecl2" |}./h|]";|] +////[|{| "id": "exportDecl2" |}[|export|] [|type|] [|{| "id": "exportDecl2_namespaceExport" |}* [|as|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "exportDecl2" |}H|]|] [|from|] "[|{| "isWriteAccess": false, "isDefinition": false, "contextRangeId": "exportDecl2" |}./h|]";|] ////[|{| "id": "exportDecl3" |}[|export|] [|type|] { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "exportDecl3" |}I|] } [|from|] "[|{| "isWriteAccess": false, "isDefinition": false, "contextRangeId": "exportDecl3" |}./i|]";|] ////[|{| "id": "exportDecl4" |}[|export|] [|type|] { j1, j2 [|as|] [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "exportDecl4" |}j3|] } [|from|] "[|{| "isWriteAccess": false, "isDefinition": false, "contextRangeId": "exportDecl4" |}./j|]";|] ////[|{| "id": "typeDecl1" |}type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeId": "typeDecl1" |}Z1|] = 1;|]