Skip to content

Commit 49bd87f

Browse files
committed
Handle import type node when handling the namespace import and reexport
Fixes #33017
1 parent 9972745 commit 49bd87f

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

src/services/importTracker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ namespace ts.FindAllReferences {
176176
const directImports = getDirectImports(moduleSymbol);
177177
if (directImports) {
178178
for (const directImport of directImports) {
179-
addIndirectUsers(getSourceFileLikeForImportDeclaration(directImport));
179+
if (!isImportTypeNode(directImport)) {
180+
addIndirectUsers(getSourceFileLikeForImportDeclaration(directImport));
181+
}
180182
}
181183
}
182184
}
Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
11
/// <reference path="fourslash.ts" />
22

33
// @Filename: /foo/types/types.ts
4-
////[|export type [|Full|] = { prop: string; };|]
4+
////[|export type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Full|] = { prop: string; };|]
55

66
// @Filename: /foo/types/index.ts
7-
////import * as foo from './types';
8-
////export { foo };
7+
////[|import * as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}foo|] from './types';|]
8+
////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}foo|] };|]
99

1010
// @Filename: /app.ts
11-
////import { foo } from './foo/types';
12-
////export type fullType = foo.Full;
11+
////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}foo|] } from './foo/types';|]
12+
////export type fullType = [|foo|].[|Full|];
1313
////type namespaceImport = typeof import('./foo/types');
14-
////type fullType2 = import('./foo/types').foo.Full;
14+
////type fullType2 = import('./foo/types').[|foo|].[|Full|];
1515

1616
verify.noErrors();
17-
const [full0Def, full0] = test.ranges();
18-
verify.referenceGroups([full0], [{
19-
definition: "type foo",
20-
ranges: [full0]
21-
}])
17+
const [full0Def, full0, foo0Def, foo0, foo1Def, foo1, foo2Def, foo2, foo3, full1, foo4, full2] = test.ranges();
18+
const fullRanges = [full0, full1, full2];
19+
const full = {
20+
definition: "type Full = {\n prop: string;\n}",
21+
ranges: fullRanges
22+
};
23+
verify.referenceGroups(fullRanges, [full]);
2224

25+
const fooTypesRanges = [foo0, foo1];
26+
const fooTypes = {
27+
definition: "import foo",
28+
ranges: fooTypesRanges
29+
};
30+
const fooAppRanges = [foo2, foo3];
31+
const fooApp = {
32+
definition: "import foo",
33+
ranges: fooAppRanges
34+
};
35+
verify.referenceGroups(fooTypesRanges, [fooTypes, fooApp]);
36+
verify.referenceGroups(fooAppRanges, [fooApp, fooTypes]);

0 commit comments

Comments
 (0)