Only check import = reference when target is Value (#32747)

This commit is contained in:
Wesley Wigham 2019-08-06 16:44:42 -07:00 committed by GitHub
parent f333684179
commit abd127f308
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 110 additions and 3 deletions

View File

@ -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);
}
}
}
}

View File

@ -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))
}

View File

@ -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
}

View File

@ -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;
}

@ -1 +1 @@
Subproject commit 6fae09b67ec6f7b27259a5c133a6961d05a4161b
Subproject commit 1e471a007968b7490563b91ed6909ae6046f3fe8