mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Fix resolving entity name of namespace member after alias is merged with type (#53387)
This commit is contained in:
parent
acfb0b53d1
commit
f43a4fe401
@ -4688,6 +4688,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
}
|
||||
symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning));
|
||||
if (!symbol && (namespace.flags & SymbolFlags.Alias)) {
|
||||
// `namespace` can be resolved further if there was a symbol merge with a re-export
|
||||
symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(resolveAlias(namespace)), right.escapedText, meaning));
|
||||
}
|
||||
if (!symbol) {
|
||||
if (!ignoreErrors) {
|
||||
const namespaceName = getFullyQualifiedName(namespace);
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
//// [tests/cases/conformance/externalModules/exportTypeMergedWithExportStarAsNamespace.ts] ////
|
||||
|
||||
//// [usage.ts]
|
||||
import { Something } from "./prelude"
|
||||
export const myValue: Something<string> = Something.of("abc")
|
||||
export type MyType = Something.SubType<string>
|
||||
|
||||
//// [Something.ts]
|
||||
export type Something<A> = { value: A }
|
||||
export type SubType<A> = { value: A }
|
||||
export declare function of<A>(value: A): Something<A>
|
||||
|
||||
//// [prelude.ts]
|
||||
import * as S from "./Something"
|
||||
export * as Something from "./Something"
|
||||
export type Something<A> = S.Something<A>
|
||||
|
||||
|
||||
//// [Something.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//// [prelude.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Something = void 0;
|
||||
exports.Something = require("./Something");
|
||||
//// [usage.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.myValue = void 0;
|
||||
var prelude_1 = require("./prelude");
|
||||
exports.myValue = prelude_1.Something.of("abc");
|
||||
@ -0,0 +1,51 @@
|
||||
=== tests/cases/conformance/externalModules/usage.ts ===
|
||||
import { Something } from "./prelude"
|
||||
>Something : Symbol(Something, Decl(usage.ts, 0, 8))
|
||||
|
||||
export const myValue: Something<string> = Something.of("abc")
|
||||
>myValue : Symbol(myValue, Decl(usage.ts, 1, 12))
|
||||
>Something : Symbol(Something, Decl(usage.ts, 0, 8))
|
||||
>Something.of : Symbol(of, Decl(Something.ts, 1, 37))
|
||||
>Something : Symbol(Something, Decl(usage.ts, 0, 8))
|
||||
>of : Symbol(of, Decl(Something.ts, 1, 37))
|
||||
|
||||
export type MyType = Something.SubType<string>
|
||||
>MyType : Symbol(MyType, Decl(usage.ts, 1, 61))
|
||||
>Something : Symbol(Something, Decl(usage.ts, 0, 8))
|
||||
>SubType : Symbol(SubType, Decl(Something.ts, 0, 39))
|
||||
|
||||
=== tests/cases/conformance/externalModules/Something.ts ===
|
||||
export type Something<A> = { value: A }
|
||||
>Something : Symbol(Something, Decl(Something.ts, 0, 0))
|
||||
>A : Symbol(A, Decl(Something.ts, 0, 22))
|
||||
>value : Symbol(value, Decl(Something.ts, 0, 28))
|
||||
>A : Symbol(A, Decl(Something.ts, 0, 22))
|
||||
|
||||
export type SubType<A> = { value: A }
|
||||
>SubType : Symbol(SubType, Decl(Something.ts, 0, 39))
|
||||
>A : Symbol(A, Decl(Something.ts, 1, 20))
|
||||
>value : Symbol(value, Decl(Something.ts, 1, 26))
|
||||
>A : Symbol(A, Decl(Something.ts, 1, 20))
|
||||
|
||||
export declare function of<A>(value: A): Something<A>
|
||||
>of : Symbol(of, Decl(Something.ts, 1, 37))
|
||||
>A : Symbol(A, Decl(Something.ts, 2, 27))
|
||||
>value : Symbol(value, Decl(Something.ts, 2, 30))
|
||||
>A : Symbol(A, Decl(Something.ts, 2, 27))
|
||||
>Something : Symbol(Something, Decl(Something.ts, 0, 0))
|
||||
>A : Symbol(A, Decl(Something.ts, 2, 27))
|
||||
|
||||
=== tests/cases/conformance/externalModules/prelude.ts ===
|
||||
import * as S from "./Something"
|
||||
>S : Symbol(S, Decl(prelude.ts, 0, 6))
|
||||
|
||||
export * as Something from "./Something"
|
||||
>Something : Symbol(Something, Decl(prelude.ts, 1, 6), Decl(prelude.ts, 1, 40))
|
||||
|
||||
export type Something<A> = S.Something<A>
|
||||
>Something : Symbol(Something, Decl(prelude.ts, 1, 6), Decl(prelude.ts, 1, 40))
|
||||
>A : Symbol(A, Decl(prelude.ts, 2, 22))
|
||||
>S : Symbol(S, Decl(prelude.ts, 0, 6))
|
||||
>Something : Symbol(S.Something, Decl(Something.ts, 0, 0))
|
||||
>A : Symbol(A, Decl(prelude.ts, 2, 22))
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
=== tests/cases/conformance/externalModules/usage.ts ===
|
||||
import { Something } from "./prelude"
|
||||
>Something : typeof import("tests/cases/conformance/externalModules/Something")
|
||||
|
||||
export const myValue: Something<string> = Something.of("abc")
|
||||
>myValue : Something<string>
|
||||
>Something.of("abc") : import("tests/cases/conformance/externalModules/Something").Something<string>
|
||||
>Something.of : <A>(value: A) => import("tests/cases/conformance/externalModules/Something").Something<A>
|
||||
>Something : typeof import("tests/cases/conformance/externalModules/Something")
|
||||
>of : <A>(value: A) => import("tests/cases/conformance/externalModules/Something").Something<A>
|
||||
>"abc" : "abc"
|
||||
|
||||
export type MyType = Something.SubType<string>
|
||||
>MyType : { value: string; }
|
||||
>Something : any
|
||||
|
||||
=== tests/cases/conformance/externalModules/Something.ts ===
|
||||
export type Something<A> = { value: A }
|
||||
>Something : Something<A>
|
||||
>value : A
|
||||
|
||||
export type SubType<A> = { value: A }
|
||||
>SubType : SubType<A>
|
||||
>value : A
|
||||
|
||||
export declare function of<A>(value: A): Something<A>
|
||||
>of : <A>(value: A) => Something<A>
|
||||
>value : A
|
||||
|
||||
=== tests/cases/conformance/externalModules/prelude.ts ===
|
||||
import * as S from "./Something"
|
||||
>S : typeof S
|
||||
|
||||
export * as Something from "./Something"
|
||||
>Something : typeof S
|
||||
|
||||
export type Something<A> = S.Something<A>
|
||||
>Something : Something<A>
|
||||
>S : any
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
// @Filename: usage.ts
|
||||
import { Something } from "./prelude"
|
||||
export const myValue: Something<string> = Something.of("abc")
|
||||
export type MyType = Something.SubType<string>
|
||||
|
||||
// @Filename: Something.ts
|
||||
export type Something<A> = { value: A }
|
||||
export type SubType<A> = { value: A }
|
||||
export declare function of<A>(value: A): Something<A>
|
||||
|
||||
// @Filename: prelude.ts
|
||||
import * as S from "./Something"
|
||||
export * as Something from "./Something"
|
||||
export type Something<A> = S.Something<A>
|
||||
Loading…
x
Reference in New Issue
Block a user