Skip to content

Commit abd127f

Browse files
authored
Only check import = reference when target is Value (#32747)
1 parent f333684 commit abd127f

File tree

5 files changed

+110
-3
lines changed

5 files changed

+110
-3
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,8 +2405,11 @@ namespace ts {
24052405
// This way a chain of imports can be elided if ultimately the final input is only used in a type
24062406
// position.
24072407
if (isInternalModuleImportEqualsDeclaration(node)) {
2408-
// import foo = <symbol>
2409-
checkExpressionCached(<Expression>node.moduleReference);
2408+
const target = resolveSymbol(symbol);
2409+
if (target === unknownSymbol || target.flags & SymbolFlags.Value) {
2410+
// import foo = <symbol>
2411+
checkExpressionCached(<Expression>node.moduleReference);
2412+
}
24102413
}
24112414
}
24122415
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
=== tests/cases/compiler/file.d.ts ===
2+
declare namespace dojox {
3+
>dojox : Symbol(dojox, Decl(file.d.ts, 0, 0))
4+
5+
namespace charting {
6+
>charting : Symbol(charting, Decl(file.d.ts, 0, 25))
7+
8+
namespace axis2d {
9+
>axis2d : Symbol(axis2d, Decl(file.d.ts, 1, 24))
10+
11+
export class Val { }
12+
>Val : Symbol(Val, Decl(file.d.ts, 2, 26))
13+
14+
interface common {
15+
>common : Symbol(common, Decl(file.d.ts, 3, 32), Decl(file.d.ts, 6, 13))
16+
17+
createText: object;
18+
>createText : Symbol(common.createText, Decl(file.d.ts, 4, 30))
19+
}
20+
namespace common {
21+
>common : Symbol(common, Decl(file.d.ts, 3, 32), Decl(file.d.ts, 6, 13))
22+
23+
interface createText {
24+
>createText : Symbol(createText, Decl(file.d.ts, 7, 30))
25+
26+
gfx(): string
27+
>gfx : Symbol(createText.gfx, Decl(file.d.ts, 8, 38))
28+
}
29+
}
30+
}
31+
}
32+
}
33+
declare module "dojox/charting/axis2d/common.createText" {
34+
>"dojox/charting/axis2d/common.createText" : Symbol("dojox/charting/axis2d/common.createText", Decl(file.d.ts, 14, 1))
35+
36+
import exp = dojox.charting.axis2d.common
37+
>exp : Symbol(exp, Decl(file.d.ts, 15, 58))
38+
>dojox : Symbol(dojox, Decl(file.d.ts, 0, 0))
39+
>charting : Symbol(dojox.charting, Decl(file.d.ts, 0, 25))
40+
>axis2d : Symbol(dojox.charting.axis2d, Decl(file.d.ts, 1, 24))
41+
>common : Symbol(exp, Decl(file.d.ts, 3, 32), Decl(file.d.ts, 6, 13))
42+
43+
export = exp;
44+
>exp : Symbol(exp, Decl(file.d.ts, 15, 58))
45+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
=== tests/cases/compiler/file.d.ts ===
2+
declare namespace dojox {
3+
>dojox : typeof dojox
4+
5+
namespace charting {
6+
>charting : typeof charting
7+
8+
namespace axis2d {
9+
>axis2d : typeof axis2d
10+
11+
export class Val { }
12+
>Val : Val
13+
14+
interface common {
15+
createText: object;
16+
>createText : object
17+
}
18+
namespace common {
19+
interface createText {
20+
gfx(): string
21+
>gfx : () => string
22+
}
23+
}
24+
}
25+
}
26+
}
27+
declare module "dojox/charting/axis2d/common.createText" {
28+
>"dojox/charting/axis2d/common.createText" : typeof import("dojox/charting/axis2d/common.createText")
29+
30+
import exp = dojox.charting.axis2d.common
31+
>exp : any
32+
>dojox : typeof dojox
33+
>charting : typeof dojox.charting
34+
>axis2d : typeof dojox.charting.axis2d
35+
>common : exp
36+
37+
export = exp;
38+
>exp : exp
39+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// @filename: file.d.ts
2+
declare namespace dojox {
3+
namespace charting {
4+
namespace axis2d {
5+
export class Val { }
6+
interface common {
7+
createText: object;
8+
}
9+
namespace common {
10+
interface createText {
11+
gfx(): string
12+
}
13+
}
14+
}
15+
}
16+
}
17+
declare module "dojox/charting/axis2d/common.createText" {
18+
import exp = dojox.charting.axis2d.common
19+
export = exp;
20+
}

tests/cases/user/prettier/prettier

Submodule prettier updated 198 files

0 commit comments

Comments
 (0)