-
Notifications
You must be signed in to change notification settings - Fork 664
Open
Labels
Domain: Declaration EmitRelated to declaration emit, type printingRelated to declaration emit, type printing
Description
Feels like I'm hitting all the edge cases. This can be reproduced using the following test case:
// @Filename: /packages/b/package.json
{
"name": "package-b",
"type": "module",
"exports": {
".": "./index.js"
}
}
// @Filename: /packages/b/index.js
export {};
// @Filename: /packages/b/index.d.ts
export interface B {
b: "b";
}
// @Filename: /packages/a/package.json
{
"name": "package-a",
"type": "module",
"imports": {
"#re_export": "./src/re_export.ts"
},
"exports": {
".": "./dist/index.js"
}
}
// @Filename: /packages/a/tsconfig.json
{
"compilerOptions": {
"module": "nodenext",
"outDir": "dist",
"rootDir": "src",
"declaration": true,
},
"include": ["src/**/*.ts"]
}
// @Filename: /packages/a/src/re_export.ts
import type { B } from "package-b";
declare function foo(): Promise<B>
export const re = { foo };
// @Filename: /packages/a/src/index.ts
import { re } from "#re_export";
const { foo } = re;
export { foo };
// @link: /packages/b -> /packages/a/node_modules/package-b
The relevant part are the type declarations generated for package-a
:
//// [re_export.d.ts]
import type { B } from "package-b";
declare function foo(): Promise<B>;
export declare const re: {
foo: typeof foo;
};
export {};
//// [index.d.ts]
declare const foo: () => Promise<import("../../b/index.js").B>;
export { foo };
I would have expected the following declaration:
declare const foo: () => Promise<import("package-b").B>;
export { foo };
Copilot
Metadata
Metadata
Assignees
Labels
Domain: Declaration EmitRelated to declaration emit, type printingRelated to declaration emit, type printing