Adjust typeof import name lookup to better match type query lookup
This commit is contained in:
parent
692502e99f
commit
c6734afba5
|
@ -14346,7 +14346,10 @@ namespace ts {
|
|||
let current: Identifier | undefined;
|
||||
while (current = nameStack.shift()) {
|
||||
const meaning = nameStack.length ? SymbolFlags.Namespace : targetMeaning;
|
||||
const next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning);
|
||||
// typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName`
|
||||
// That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from
|
||||
// the `exports` lookup process that only looks up namespace members which is used for most type references
|
||||
const next = node.isTypeOf ? getPropertyOfType(getTypeOfSymbol(resolveSymbol(currentNamespace)), current.escapedText) : getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning);
|
||||
if (!next) {
|
||||
error(current, Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), declarationNameToString(current));
|
||||
return links.resolvedType = errorType;
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
=== tests/cases/compiler/a.d.ts ===
|
||||
export declare class A {
|
||||
>A : Symbol(A, Decl(a.d.ts, 0, 0))
|
||||
|
||||
static foo(): void;
|
||||
>foo : Symbol(A.foo, Decl(a.d.ts, 0, 24))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/index.d.ts ===
|
||||
export const foo: typeof import("./a").A.foo;
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 0, 12))
|
||||
>A : Symbol(A, Decl(a.d.ts, 0, 0))
|
||||
>foo : Symbol(A.foo, Decl(a.d.ts, 0, 24))
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
=== tests/cases/compiler/a.d.ts ===
|
||||
export declare class A {
|
||||
>A : A
|
||||
|
||||
static foo(): void;
|
||||
>foo : () => void
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/index.d.ts ===
|
||||
export const foo: typeof import("./a").A.foo;
|
||||
>foo : () => void
|
||||
>A : any
|
||||
>foo : any
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
// @filename: a.d.ts
|
||||
export declare class A {
|
||||
static foo(): void;
|
||||
}
|
||||
|
||||
// @filename: index.d.ts
|
||||
export const foo: typeof import("./a").A.foo;
|
Loading…
Reference in a new issue