Skip to content

Commit 7eaa788

Browse files
authored
Visit the children of an import type/require call/dynamic import when looking for those (#24663)
1 parent cbbf2e4 commit 7eaa788

5 files changed

+74
-5
lines changed

src/compiler/program.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1819,11 +1819,9 @@ namespace ts {
18191819
else if (isLiteralImportTypeNode(node)) {
18201820
imports = append(imports, node.argument.literal);
18211821
}
1822-
else {
1823-
collectDynamicImportOrRequireCallsForEachChild(node);
1824-
if (hasJSDocNodes(node)) {
1825-
forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild);
1826-
}
1822+
collectDynamicImportOrRequireCallsForEachChild(node);
1823+
if (hasJSDocNodes(node)) {
1824+
forEach(node.jsDoc, collectDynamicImportOrRequireCallsForEachChild);
18271825
}
18281826
}
18291827

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)