Skip to content
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

Emit declarations using alias chains #56100

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add an extra test case
Andarist committed Feb 17, 2024
commit 9aa27219095143d1110adf72b5d5d50768b93073
49 changes: 49 additions & 0 deletions tests/baselines/reference/declarationEmitUsingAliasSymbolChain2.js
Original file line number Diff line number Diff line change
@@ -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";
Original file line number Diff line number Diff line change
@@ -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))

Original file line number Diff line number Diff line change
@@ -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 : { <T extends Function>(f: T): T; <T_1 extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T_1): Readonly<T_1>; <T_2>(o: T_2): Readonly<T_2>; }
>Object : ObjectConstructor
>freeze : { <T extends Function>(f: T): T; <T_1 extends { [idx: string]: object | U | null | undefined; }, U extends string | number | bigint | boolean | symbol>(o: T_1): Readonly<T_1>; <T_2>(o: T_2): Readonly<T_2>; }
>{ 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

34 changes: 34 additions & 0 deletions tests/cases/compiler/declarationEmitUsingAliasSymbolChain2.ts
Original file line number Diff line number Diff line change
@@ -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";