Skip to content

Commit 40af70b

Browse files
committed
Visit the children of an import type/require call/dynamic import when looking for those (microsoft#24663)
1 parent c52fb0e commit 40af70b

5 files changed

+74
-5
lines changed

src/compiler/program.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1802,11 +1802,9 @@ namespace ts {
18021802
else if (isLiteralImportTypeNode(node)) {
18031803
imports = append(imports, node.argument.literal);
18041804
}
1805-
else {
1806-
collectDynamicImportOrRequireCallsForEachChild(node);
1807-
if (hasJSDocNodes(node)) {
1808-
forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild);
1809-
}
1805+
collectDynamicImportOrRequireCallsForEachChild(node);
1806+
if (hasJSDocNodes(node)) {
1807+
forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild);
18101808
}
18111809
}
18121810

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [tests/cases/compiler/importUsedInGenericImportResolves.ts] ////
2+
3+
//// [test1.d.ts]
4+
export interface T<P> {
5+
a: P;
6+
}
7+
8+
//// [test2.d.ts]
9+
export declare const theme: { a: string }
10+
11+
//// [test3.ts]
12+
export const a: import("./test1").T<typeof import("./test2").theme> = null as any;
13+
14+
//// [test3.js]
15+
"use strict";
16+
exports.__esModule = true;
17+
exports.a = null;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/test1.d.ts ===
2+
export interface T<P> {
3+
>T : Symbol(T, Decl(test1.d.ts, 0, 0))
4+
>P : Symbol(P, Decl(test1.d.ts, 0, 19))
5+
6+
a: P;
7+
>a : Symbol(T.a, Decl(test1.d.ts, 0, 23))
8+
>P : Symbol(P, Decl(test1.d.ts, 0, 19))
9+
}
10+
11+
=== tests/cases/compiler/test2.d.ts ===
12+
export declare const theme: { a: string }
13+
>theme : Symbol(theme, Decl(test2.d.ts, 0, 20))
14+
>a : Symbol(a, Decl(test2.d.ts, 0, 29))
15+
16+
=== tests/cases/compiler/test3.ts ===
17+
export const a: import("./test1").T<typeof import("./test2").theme> = null as any;
18+
>a : Symbol(a, Decl(test3.ts, 0, 12))
19+
>T : Symbol(T, Decl(test1.d.ts, 0, 0))
20+
>theme : Symbol(theme, Decl(test2.d.ts, 0, 20))
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/compiler/test1.d.ts ===
2+
export interface T<P> {
3+
>T : T<P>
4+
>P : P
5+
6+
a: P;
7+
>a : P
8+
>P : P
9+
}
10+
11+
=== tests/cases/compiler/test2.d.ts ===
12+
export declare const theme: { a: string }
13+
>theme : { a: string; }
14+
>a : string
15+
16+
=== tests/cases/compiler/test3.ts ===
17+
export const a: import("./test1").T<typeof import("./test2").theme> = null as any;
18+
>a : import("tests/cases/compiler/test1").T<{ a: string; }>
19+
>T : import("tests/cases/compiler/test1").T<P>
20+
>theme : any
21+
>null as any : any
22+
>null : null
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @filename: test1.d.ts
2+
export interface T<P> {
3+
a: P;
4+
}
5+
6+
// @filename: test2.d.ts
7+
export declare const theme: { a: string }
8+
9+
// @filename: test3.ts
10+
export const a: import("./test1").T<typeof import("./test2").theme> = null as any;

0 commit comments

Comments
 (0)