mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Fixes searches for export * as 'identifier' (#39533)
* Fixes searches for export * as 'identifier' Fixes #39006 * Fix the context span to export declaration (was incorrectly set to sourceFile in prev commit)
This commit is contained in:
parent
bf1ea6508b
commit
b397d1fd4a
@ -132,6 +132,7 @@ namespace ts.FindAllReferences {
|
||||
return node.parent.parent;
|
||||
|
||||
case SyntaxKind.ImportClause:
|
||||
case SyntaxKind.NamespaceExport:
|
||||
return node.parent;
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -1,16 +1,20 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @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]);
|
||||
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]);
|
||||
|
||||
@ -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;|]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user