diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 41908c157877b..e3f80502542c7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5591,7 +5591,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (nodeIsSynthesized(importRef)) continue; // Synthetic names can't be resolved by `resolveExternalModuleName` - they'll cause a debug assert if they error const resolvedModule = resolveExternalModuleName(enclosingDeclaration, importRef, /*ignoreErrors*/ true); if (!resolvedModule) continue; - const ref = getAliasForSymbolInContainer(resolvedModule, symbol); + const ref = getAliasChainForSymbolInContainer(resolvedModule, symbol); if (!ref) continue; results = append(results, resolvedModule); } @@ -5608,7 +5608,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { for (const file of otherFiles) { if (!isExternalModule(file)) continue; const sym = getSymbolOfDeclaration(file); - const ref = getAliasForSymbolInContainer(sym, symbol); + const ref = getAliasChainForSymbolInContainer(sym, symbol); if (!ref) continue; results = append(results, sym); } @@ -5647,7 +5647,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!length(candidates)) { return undefined; } - const containers = mapDefined(candidates, candidate => getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined); + const containers = mapDefined(candidates, candidate => getAliasChainForSymbolInContainer(candidate, symbol) ? candidate : undefined); let bestContainers: Symbol[] = []; let alternativeContainers: Symbol[] = []; @@ -5713,27 +5713,38 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } - function getAliasForSymbolInContainer(container: Symbol, symbol: Symbol) { + function getAliasChainForSymbolInContainer(container: Symbol, symbol: Symbol) { if (container === getParentOfSymbol(symbol)) { // fast path, `symbol` is either already the alias or isn't aliased - return symbol; + return [symbol]; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol const exportEquals = container.exports && container.exports.get(InternalSymbolName.ExportEquals); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { - return container; - } - const exports = getExportsOfSymbol(container); - const quick = exports.get(symbol.escapedName); - if (quick && getSymbolIfSameReference(quick, symbol)) { - return quick; + return [container]; } - return forEachEntry(exports, exported => { - if (getSymbolIfSameReference(exported, symbol)) { - return exported; + return getAliasChainRecursively(container); + + function getAliasChainRecursively(container: Symbol): Symbol[] | undefined { + const exports = getExportsOfSymbol(container); + const quick = exports.get(symbol.escapedName); + if (quick && getSymbolIfSameReference(quick, symbol)) { + return [quick]; } - }); + return forEachEntry(exports, exported => { + if (getSymbolIfSameReference(exported, symbol)) { + return [exported]; + } + if (exported.flags & SymbolFlags.Alias) { + const aliasChain = getAliasChainRecursively(resolveAlias(exported)); + if (aliasChain) { + aliasChain.unshift(exported); + return aliasChain; + } + } + }); + } } /** @@ -7984,7 +7995,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { accessibleSymbolChain = parentChain; break; } - accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); + if (accessibleSymbolChain) { + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain); + break; + } + const aliasChain = getAliasChainForSymbolInContainer(parent, symbol); + if (aliasChain) { + accessibleSymbolChain = parentChain.concat(aliasChain); + break; + } + accessibleSymbolChain = parentChain.concat(symbol); break; } } diff --git a/tests/baselines/reference/declarationEmitUsingAliasSymbolChain1.js b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain1.js new file mode 100644 index 0000000000000..a7b831e6a58a9 --- /dev/null +++ b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain1.js @@ -0,0 +1,82 @@ +//// [tests/cases/compiler/declarationEmitUsingAliasSymbolChain1.ts] //// + +//// [Data.d.ts] +import type * as Types from "./Types.js"; +import type * as Equal from "./Equal.js"; + +export type Data> | ReadonlyArray> = + Readonly & Equal.Equal; + +export declare const TaggedClass: ( + tag: Key, +) => new >( + args: Types.Equals, {}> extends true + ? void + : Omit, +) => Data< + A & { + _tag: Key; + } +>; + +//// [Equal.d.ts] +import * as Hash from "./Hash.js"; + +export declare const symbol: unique symbol; + +export interface Equal extends Hash.Hash { + [symbol](that: Equal): boolean; +} + +//// [Hash.d.ts] +export declare const symbol: unique symbol; + +export interface Hash { + [symbol](): number; +} + +//// [Types.d.ts] +export type Equals = (() => T extends X ? 1 : 2) extends < + T, +>() => T extends Y ? 1 : 2 + ? true + : false; + +//// [index.d.ts] +export * as Data from "./Data.js"; +export * as Equal from "./Equal.js"; +export * as Types from "./Types.js"; + +//// [effect.cjs.d.ts] +export * from "./declarations/src/index"; + +//// [package.json] +{ + "name": "effect", + "exports": { + ".": "./dist/effect.cjs.js" + } +} + +//// [index.ts] +import { Data } from "effect"; +export class Foo extends Data.TaggedClass("Foo")<{}> {} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Foo = void 0; +const effect_1 = require("effect"); +class Foo extends effect_1.Data.TaggedClass("Foo") { +} +exports.Foo = Foo; + + +//// [index.d.ts] +import { Data } from "effect"; +declare const Foo_base: new >(args: import("effect").Types.Equals, {}> extends true ? void : Omit) => Data.Data; +export declare class Foo extends Foo_base<{}> { +} +export {}; diff --git a/tests/baselines/reference/declarationEmitUsingAliasSymbolChain1.symbols b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain1.symbols new file mode 100644 index 0000000000000..8e30c5a30d55d --- /dev/null +++ b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain1.symbols @@ -0,0 +1,137 @@ +//// [tests/cases/compiler/declarationEmitUsingAliasSymbolChain1.ts] //// + +=== node_modules/effect/dist/declarations/src/Data.d.ts === +import type * as Types from "./Types.js"; +>Types : Symbol(Types, Decl(Data.d.ts, 0, 11)) + +import type * as Equal from "./Equal.js"; +>Equal : Symbol(Equal, Decl(Data.d.ts, 1, 11)) + +export type Data> | ReadonlyArray> = +>Data : Symbol(Data, Decl(Data.d.ts, 1, 41)) +>A : Symbol(A, Decl(Data.d.ts, 3, 17)) +>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more) + + Readonly & Equal.Equal; +>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --)) +>A : Symbol(A, Decl(Data.d.ts, 3, 17)) +>Equal : Symbol(Equal, Decl(Data.d.ts, 1, 11)) +>Equal : Symbol(Equal.Equal, Decl(Equal.d.ts, 2, 43)) + +export declare const TaggedClass: ( +>TaggedClass : Symbol(TaggedClass, Decl(Data.d.ts, 6, 20)) +>Key : Symbol(Key, Decl(Data.d.ts, 6, 35)) + + tag: Key, +>tag : Symbol(tag, Decl(Data.d.ts, 6, 55)) +>Key : Symbol(Key, Decl(Data.d.ts, 6, 35)) + +) => new >( +>A : Symbol(A, Decl(Data.d.ts, 8, 10)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + + args: Types.Equals, {}> extends true +>args : Symbol(args, Decl(Data.d.ts, 8, 41)) +>Types : Symbol(Types, Decl(Data.d.ts, 0, 11)) +>Equals : Symbol(Types.Equals, Decl(Types.d.ts, 0, 0)) +>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) +>A : Symbol(A, Decl(Data.d.ts, 8, 10)) +>Equal : Symbol(Equal, Decl(Data.d.ts, 1, 11)) +>Equal : Symbol(Equal.Equal, Decl(Equal.d.ts, 2, 43)) + + ? void + : Omit, +>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) +>A : Symbol(A, Decl(Data.d.ts, 8, 10)) +>Equal : Symbol(Equal, Decl(Data.d.ts, 1, 11)) +>Equal : Symbol(Equal.Equal, Decl(Equal.d.ts, 2, 43)) + +) => Data< +>Data : Symbol(Data, Decl(Data.d.ts, 1, 41)) + + A & { +>A : Symbol(A, Decl(Data.d.ts, 8, 10)) + + _tag: Key; +>_tag : Symbol(_tag, Decl(Data.d.ts, 13, 7)) +>Key : Symbol(Key, Decl(Data.d.ts, 6, 35)) + } +>; + +=== node_modules/effect/dist/declarations/src/Equal.d.ts === +import * as Hash from "./Hash.js"; +>Hash : Symbol(Hash, Decl(Equal.d.ts, 0, 6)) + +export declare const symbol: unique symbol; +>symbol : Symbol(symbol, Decl(Equal.d.ts, 2, 20)) + +export interface Equal extends Hash.Hash { +>Equal : Symbol(Equal, Decl(Equal.d.ts, 2, 43)) +>Hash.Hash : Symbol(Hash.Hash, Decl(Hash.d.ts, 0, 43)) +>Hash : Symbol(Hash, Decl(Equal.d.ts, 0, 6)) +>Hash : Symbol(Hash.Hash, Decl(Hash.d.ts, 0, 43)) + + [symbol](that: Equal): boolean; +>[symbol] : Symbol(Equal[symbol], Decl(Equal.d.ts, 4, 42)) +>symbol : Symbol(symbol, Decl(Equal.d.ts, 2, 20)) +>that : Symbol(that, Decl(Equal.d.ts, 5, 11)) +>Equal : Symbol(Equal, Decl(Equal.d.ts, 2, 43)) +} + +=== node_modules/effect/dist/declarations/src/Hash.d.ts === +export declare const symbol: unique symbol; +>symbol : Symbol(symbol, Decl(Hash.d.ts, 0, 20)) + +export interface Hash { +>Hash : Symbol(Hash, Decl(Hash.d.ts, 0, 43)) + + [symbol](): number; +>[symbol] : Symbol(Hash[symbol], Decl(Hash.d.ts, 2, 23)) +>symbol : Symbol(symbol, Decl(Hash.d.ts, 0, 20)) +} + +=== node_modules/effect/dist/declarations/src/Types.d.ts === +export type Equals = (() => T extends X ? 1 : 2) extends < +>Equals : Symbol(Equals, Decl(Types.d.ts, 0, 0)) +>X : Symbol(X, Decl(Types.d.ts, 0, 19)) +>Y : Symbol(Y, Decl(Types.d.ts, 0, 21)) +>T : Symbol(T, Decl(Types.d.ts, 0, 29)) +>T : Symbol(T, Decl(Types.d.ts, 0, 29)) +>X : Symbol(X, Decl(Types.d.ts, 0, 19)) + + T, +>T : Symbol(T, Decl(Types.d.ts, 0, 67)) + +>() => T extends Y ? 1 : 2 +>T : Symbol(T, Decl(Types.d.ts, 0, 67)) +>Y : Symbol(Y, Decl(Types.d.ts, 0, 21)) + + ? true + : false; + +=== node_modules/effect/dist/declarations/src/index.d.ts === +export * as Data from "./Data.js"; +>Data : Symbol(Data, Decl(index.d.ts, 0, 6)) + +export * as Equal from "./Equal.js"; +>Equal : Symbol(Equal, Decl(index.d.ts, 1, 6)) + +export * as Types from "./Types.js"; +>Types : Symbol(Types, Decl(index.d.ts, 2, 6)) + +=== node_modules/effect/dist/effect.cjs.d.ts === + +export * from "./declarations/src/index"; + +=== src/index.ts === +import { Data } from "effect"; +>Data : Symbol(Data, Decl(index.ts, 0, 8)) + +export class Foo extends Data.TaggedClass("Foo")<{}> {} +>Foo : Symbol(Foo, Decl(index.ts, 0, 30)) +>Data.TaggedClass : Symbol(Data.TaggedClass, Decl(Data.d.ts, 6, 20)) +>Data : Symbol(Data, Decl(index.ts, 0, 8)) +>TaggedClass : Symbol(Data.TaggedClass, Decl(Data.d.ts, 6, 20)) + diff --git a/tests/baselines/reference/declarationEmitUsingAliasSymbolChain1.types b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain1.types new file mode 100644 index 0000000000000..5901d3ee80585 --- /dev/null +++ b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain1.types @@ -0,0 +1,103 @@ +//// [tests/cases/compiler/declarationEmitUsingAliasSymbolChain1.ts] //// + +=== node_modules/effect/dist/declarations/src/Data.d.ts === +import type * as Types from "./Types.js"; +>Types : typeof Types + +import type * as Equal from "./Equal.js"; +>Equal : typeof Equal + +export type Data> | ReadonlyArray> = +>Data : Data + + Readonly & Equal.Equal; +>Equal : any + +export declare const TaggedClass: ( +>TaggedClass : (tag: Key) => new >(args: Types.Equals, {}> extends true ? void : Omit) => Data + + tag: Key, +>tag : Key + +) => new >( + args: Types.Equals, {}> extends true +>args : Types.Equals, {}> extends true ? void : Omit +>Types : any +>Equal : any +>true : true + + ? void + : Omit, +>Equal : any + +) => Data< + A & { + _tag: Key; +>_tag : Key + } +>; + +=== node_modules/effect/dist/declarations/src/Equal.d.ts === +import * as Hash from "./Hash.js"; +>Hash : typeof Hash + +export declare const symbol: unique symbol; +>symbol : unique symbol + +export interface Equal extends Hash.Hash { +>Hash : typeof Hash + + [symbol](that: Equal): boolean; +>[symbol] : (that: Equal) => boolean +>symbol : unique symbol +>that : Equal +} + +=== node_modules/effect/dist/declarations/src/Hash.d.ts === +export declare const symbol: unique symbol; +>symbol : unique symbol + +export interface Hash { + [symbol](): number; +>[symbol] : () => number +>symbol : unique symbol +} + +=== node_modules/effect/dist/declarations/src/Types.d.ts === +export type Equals = (() => T extends X ? 1 : 2) extends < +>Equals : Equals + + T, +>() => T extends Y ? 1 : 2 + ? true +>true : true + + : false; +>false : false + +=== node_modules/effect/dist/declarations/src/index.d.ts === +export * as Data from "./Data.js"; +>Data : typeof import("node_modules/effect/dist/declarations/src/Data") + +export * as Equal from "./Equal.js"; +>Equal : typeof import("node_modules/effect/dist/declarations/src/Equal") + +export * as Types from "./Types.js"; +>Types : typeof import("node_modules/effect/dist/declarations/src/Types") + +=== node_modules/effect/dist/effect.cjs.d.ts === + +export * from "./declarations/src/index"; + +=== src/index.ts === +import { Data } from "effect"; +>Data : typeof Data + +export class Foo extends Data.TaggedClass("Foo")<{}> {} +>Foo : Foo +>Data.TaggedClass("Foo") : Data.Data<{ _tag: "Foo"; }> +>Data.TaggedClass : (tag: Key) => new >(args: import("node_modules/effect/dist/effect.cjs").Types.Equals, {}> extends true ? void : Omit) => Data.Data +>Data : typeof Data +>TaggedClass : (tag: Key) => new >(args: import("node_modules/effect/dist/effect.cjs").Types.Equals, {}> extends true ? void : Omit) => Data.Data +>"Foo" : "Foo" + diff --git a/tests/baselines/reference/declarationEmitUsingAliasSymbolChain2.js b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain2.js new file mode 100644 index 0000000000000..d9efd0a14e2f6 --- /dev/null +++ b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain2.js @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/declarationEmitUsingAliasSymbolChain2.ts] //// + +//// [index.d.ts] +import * as DefaultExport from "./internal/default_exports"; +export { DefaultExport as default }; +export * as BaseWindow from "./internal/windows/basewindow"; + +//// [default_exports.d.ts] +export { default as BaseWindow } from "./windows/basewindow"; + +//// [basewindow.d.ts] +interface BaseWindow {} +export interface BaseWindowConstructor {} +declare const BaseWindow: BaseWindowConstructor; +export default BaseWindow; + + +//// [widget-config.d.ts] +import type UI from "../../lib/index"; +export interface WidgetFactory { + instantiator(parentWindow: UI.BaseWindow): void; +} + +//// [widget-factory.ts] +import {WidgetFactory} from "../../lib-utils/shared-types/widget-config"; + +declare const instantiator: WidgetFactory['instantiator']; + +export default Object.freeze({ + instantiator +}); + +import type * as __synthetic_export_lib_1 from "../../lib/index"; + + +//// [widget-factory.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Object.freeze({ + instantiator: instantiator +}); + + +//// [widget-factory.d.ts] +declare const _default: Readonly<{ + instantiator: (parentWindow: __synthetic_export_lib_1.default.BaseWindow) => void; +}>; +export default _default; +import type * as __synthetic_export_lib_1 from "../../lib/index"; diff --git a/tests/baselines/reference/declarationEmitUsingAliasSymbolChain2.symbols b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain2.symbols new file mode 100644 index 0000000000000..05f9494ba10d7 --- /dev/null +++ b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain2.symbols @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/declarationEmitUsingAliasSymbolChain2.ts] //// + +=== lib/index.d.ts === +import * as DefaultExport from "./internal/default_exports"; +>DefaultExport : Symbol(DefaultExport, Decl(index.d.ts, 0, 6)) + +export { DefaultExport as default }; +>DefaultExport : Symbol(DefaultExport, Decl(index.d.ts, 0, 6)) +>default : Symbol(default, Decl(index.d.ts, 1, 8)) + +export * as BaseWindow from "./internal/windows/basewindow"; +>BaseWindow : Symbol(BaseWindow, Decl(index.d.ts, 2, 6)) + +=== lib/internal/default_exports.d.ts === +export { default as BaseWindow } from "./windows/basewindow"; +>default : Symbol(default, Decl(basewindow.d.ts, 2, 48)) +>BaseWindow : Symbol(BaseWindow, Decl(default_exports.d.ts, 0, 8)) + +=== lib/internal/windows/basewindow.d.ts === +interface BaseWindow {} +>BaseWindow : Symbol(BaseWindow, Decl(basewindow.d.ts, 0, 0), Decl(basewindow.d.ts, 2, 13)) + +export interface BaseWindowConstructor {} +>BaseWindowConstructor : Symbol(BaseWindowConstructor, Decl(basewindow.d.ts, 0, 23)) + +declare const BaseWindow: BaseWindowConstructor; +>BaseWindow : Symbol(BaseWindow, Decl(basewindow.d.ts, 0, 0), Decl(basewindow.d.ts, 2, 13)) +>BaseWindowConstructor : Symbol(BaseWindowConstructor, Decl(basewindow.d.ts, 0, 23)) + +export default BaseWindow; +>BaseWindow : Symbol(BaseWindow, Decl(basewindow.d.ts, 0, 0), Decl(basewindow.d.ts, 2, 13)) + + +=== lib-utils/shared-types/widget-config.d.ts === +import type UI from "../../lib/index"; +>UI : Symbol(UI, Decl(widget-config.d.ts, 0, 6)) + +export interface WidgetFactory { +>WidgetFactory : Symbol(WidgetFactory, Decl(widget-config.d.ts, 0, 38)) + + instantiator(parentWindow: UI.BaseWindow): void; +>instantiator : Symbol(WidgetFactory.instantiator, Decl(widget-config.d.ts, 1, 32)) +>parentWindow : Symbol(parentWindow, Decl(widget-config.d.ts, 2, 17)) +>UI : Symbol(UI, Decl(widget-config.d.ts, 0, 6)) +>BaseWindow : Symbol(UI.BaseWindow, Decl(default_exports.d.ts, 0, 8)) +} + +=== app/navigator/widget-factory.ts === +import {WidgetFactory} from "../../lib-utils/shared-types/widget-config"; +>WidgetFactory : Symbol(WidgetFactory, Decl(widget-factory.ts, 0, 8)) + +declare const instantiator: WidgetFactory['instantiator']; +>instantiator : Symbol(instantiator, Decl(widget-factory.ts, 2, 13)) +>WidgetFactory : Symbol(WidgetFactory, Decl(widget-factory.ts, 0, 8)) + +export default Object.freeze({ +>Object.freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>freeze : Symbol(ObjectConstructor.freeze, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + instantiator +>instantiator : Symbol(instantiator, Decl(widget-factory.ts, 4, 30)) + +}); + +import type * as __synthetic_export_lib_1 from "../../lib/index"; +>__synthetic_export_lib_1 : Symbol(__synthetic_export_lib_1, Decl(widget-factory.ts, 8, 11)) + diff --git a/tests/baselines/reference/declarationEmitUsingAliasSymbolChain2.types b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain2.types new file mode 100644 index 0000000000000..3f041758bea61 --- /dev/null +++ b/tests/baselines/reference/declarationEmitUsingAliasSymbolChain2.types @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/declarationEmitUsingAliasSymbolChain2.ts] //// + +=== lib/index.d.ts === +import * as DefaultExport from "./internal/default_exports"; +>DefaultExport : typeof DefaultExport + +export { DefaultExport as default }; +>DefaultExport : typeof DefaultExport +>default : typeof DefaultExport + +export * as BaseWindow from "./internal/windows/basewindow"; +>BaseWindow : typeof import("lib/internal/windows/basewindow") + +=== lib/internal/default_exports.d.ts === +export { default as BaseWindow } from "./windows/basewindow"; +>default : import("lib/internal/windows/basewindow").BaseWindowConstructor +>BaseWindow : import("lib/internal/windows/basewindow").BaseWindowConstructor + +=== lib/internal/windows/basewindow.d.ts === +interface BaseWindow {} +export interface BaseWindowConstructor {} +declare const BaseWindow: BaseWindowConstructor; +>BaseWindow : BaseWindowConstructor + +export default BaseWindow; +>BaseWindow : BaseWindow + + +=== lib-utils/shared-types/widget-config.d.ts === +import type UI from "../../lib/index"; +>UI : any + +export interface WidgetFactory { + instantiator(parentWindow: UI.BaseWindow): void; +>instantiator : (parentWindow: UI.BaseWindow) => void +>parentWindow : UI.BaseWindow +>UI : any +} + +=== app/navigator/widget-factory.ts === +import {WidgetFactory} from "../../lib-utils/shared-types/widget-config"; +>WidgetFactory : any + +declare const instantiator: WidgetFactory['instantiator']; +>instantiator : (parentWindow: __synthetic_export_lib_1.default.BaseWindow) => void + +export default Object.freeze({ +>Object.freeze({ instantiator}) : Readonly<{ instantiator: (parentWindow: __synthetic_export_lib_1.default.BaseWindow) => void; }> +>Object.freeze : { (f: T): T; (o: T_1): Readonly; (o: T_2): Readonly; } +>Object : ObjectConstructor +>freeze : { (f: T): T; (o: T_1): Readonly; (o: T_2): Readonly; } +>{ instantiator} : { instantiator: (parentWindow: __synthetic_export_lib_1.default.BaseWindow) => void; } + + instantiator +>instantiator : (parentWindow: __synthetic_export_lib_1.default.BaseWindow) => void + +}); + +import type * as __synthetic_export_lib_1 from "../../lib/index"; +>__synthetic_export_lib_1 : typeof __synthetic_export_lib_1 + diff --git a/tests/cases/compiler/declarationEmitUsingAliasSymbolChain1.ts b/tests/cases/compiler/declarationEmitUsingAliasSymbolChain1.ts new file mode 100644 index 0000000000000..0021df970f97f --- /dev/null +++ b/tests/cases/compiler/declarationEmitUsingAliasSymbolChain1.ts @@ -0,0 +1,65 @@ +// @strict: true +// @declaration: true +// @module: nodenext + +// @filename: node_modules/effect/dist/declarations/src/Data.d.ts +import type * as Types from "./Types.js"; +import type * as Equal from "./Equal.js"; + +export type Data> | ReadonlyArray> = + Readonly & Equal.Equal; + +export declare const TaggedClass: ( + tag: Key, +) => new >( + args: Types.Equals, {}> extends true + ? void + : Omit, +) => Data< + A & { + _tag: Key; + } +>; + +// @filename: node_modules/effect/dist/declarations/src/Equal.d.ts +import * as Hash from "./Hash.js"; + +export declare const symbol: unique symbol; + +export interface Equal extends Hash.Hash { + [symbol](that: Equal): boolean; +} + +// @filename: node_modules/effect/dist/declarations/src/Hash.d.ts +export declare const symbol: unique symbol; + +export interface Hash { + [symbol](): number; +} + +// @filename: node_modules/effect/dist/declarations/src/Types.d.ts +export type Equals = (() => T extends X ? 1 : 2) extends < + T, +>() => T extends Y ? 1 : 2 + ? true + : false; + +// @filename: node_modules/effect/dist/declarations/src/index.d.ts +export * as Data from "./Data.js"; +export * as Equal from "./Equal.js"; +export * as Types from "./Types.js"; + +// @filename: node_modules/effect/dist/effect.cjs.d.ts +export * from "./declarations/src/index"; + +// @filename: node_modules/effect/package.json +{ + "name": "effect", + "exports": { + ".": "./dist/effect.cjs.js" + } +} + +// @filename: src/index.ts +import { Data } from "effect"; +export class Foo extends Data.TaggedClass("Foo")<{}> {} \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitUsingAliasSymbolChain2.ts b/tests/cases/compiler/declarationEmitUsingAliasSymbolChain2.ts new file mode 100644 index 0000000000000..6ffcd5c1906d9 --- /dev/null +++ b/tests/cases/compiler/declarationEmitUsingAliasSymbolChain2.ts @@ -0,0 +1,34 @@ +// @strict: true +// @declaration: true + +// @filename: lib/index.d.ts +import * as DefaultExport from "./internal/default_exports"; +export { DefaultExport as default }; +export * as BaseWindow from "./internal/windows/basewindow"; + +// @filename: lib/internal/default_exports.d.ts +export { default as BaseWindow } from "./windows/basewindow"; + +// @filename: lib/internal/windows/basewindow.d.ts +interface BaseWindow {} +export interface BaseWindowConstructor {} +declare const BaseWindow: BaseWindowConstructor; +export default BaseWindow; + + +// @filename: lib-utils/shared-types/widget-config.d.ts +import type UI from "../../lib/index"; +export interface WidgetFactory { + instantiator(parentWindow: UI.BaseWindow): void; +} + +// @filename: app/navigator/widget-factory.ts +import {WidgetFactory} from "../../lib-utils/shared-types/widget-config"; + +declare const instantiator: WidgetFactory['instantiator']; + +export default Object.freeze({ + instantiator +}); + +import type * as __synthetic_export_lib_1 from "../../lib/index";