Skip to content

Only check import = reference when target is Value #32747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2405,8 +2405,11 @@ namespace ts {
// This way a chain of imports can be elided if ultimately the final input is only used in a type
// position.
if (isInternalModuleImportEqualsDeclaration(node)) {
// import foo = <symbol>
checkExpressionCached(<Expression>node.moduleReference);
const target = resolveSymbol(symbol);
if (target === unknownSymbol || target.flags & SymbolFlags.Value) {
// import foo = <symbol>
checkExpressionCached(<Expression>node.moduleReference);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
=== tests/cases/compiler/file.d.ts ===
declare namespace dojox {
>dojox : Symbol(dojox, Decl(file.d.ts, 0, 0))

namespace charting {
>charting : Symbol(charting, Decl(file.d.ts, 0, 25))

namespace axis2d {
>axis2d : Symbol(axis2d, Decl(file.d.ts, 1, 24))

export class Val { }
>Val : Symbol(Val, Decl(file.d.ts, 2, 26))

interface common {
>common : Symbol(common, Decl(file.d.ts, 3, 32), Decl(file.d.ts, 6, 13))

createText: object;
>createText : Symbol(common.createText, Decl(file.d.ts, 4, 30))
}
namespace common {
>common : Symbol(common, Decl(file.d.ts, 3, 32), Decl(file.d.ts, 6, 13))

interface createText {
>createText : Symbol(createText, Decl(file.d.ts, 7, 30))

gfx(): string
>gfx : Symbol(createText.gfx, Decl(file.d.ts, 8, 38))
}
}
}
}
}
declare module "dojox/charting/axis2d/common.createText" {
>"dojox/charting/axis2d/common.createText" : Symbol("dojox/charting/axis2d/common.createText", Decl(file.d.ts, 14, 1))

import exp = dojox.charting.axis2d.common
>exp : Symbol(exp, Decl(file.d.ts, 15, 58))
>dojox : Symbol(dojox, Decl(file.d.ts, 0, 0))
>charting : Symbol(dojox.charting, Decl(file.d.ts, 0, 25))
>axis2d : Symbol(dojox.charting.axis2d, Decl(file.d.ts, 1, 24))
>common : Symbol(exp, Decl(file.d.ts, 3, 32), Decl(file.d.ts, 6, 13))

export = exp;
>exp : Symbol(exp, Decl(file.d.ts, 15, 58))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
=== tests/cases/compiler/file.d.ts ===
declare namespace dojox {
>dojox : typeof dojox

namespace charting {
>charting : typeof charting

namespace axis2d {
>axis2d : typeof axis2d

export class Val { }
>Val : Val

interface common {
createText: object;
>createText : object
}
namespace common {
interface createText {
gfx(): string
>gfx : () => string
}
}
}
}
}
declare module "dojox/charting/axis2d/common.createText" {
>"dojox/charting/axis2d/common.createText" : typeof import("dojox/charting/axis2d/common.createText")

import exp = dojox.charting.axis2d.common
>exp : any
>dojox : typeof dojox
>charting : typeof dojox.charting
>axis2d : typeof dojox.charting.axis2d
>common : exp

export = exp;
>exp : exp
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// @filename: file.d.ts
declare namespace dojox {
namespace charting {
namespace axis2d {
export class Val { }
interface common {
createText: object;
}
namespace common {
interface createText {
gfx(): string
}
}
}
}
}
declare module "dojox/charting/axis2d/common.createText" {
import exp = dojox.charting.axis2d.common
export = exp;
}
2 changes: 1 addition & 1 deletion tests/cases/user/prettier/prettier
Submodule prettier updated 198 files