Swatinem / rollup-plugin-dts

A rollup plugin to generate .d.ts rollup files for your typescript project
GNU Lesser General Public License v3.0
815 stars 71 forks source link

[bug] Introduces a variable that cirtularly references itself #307

Open nicolo-ribaudo opened 6 months ago

nicolo-ribaudo commented 6 months ago

Checklist

Code Snipped

// index.d.ts
declare namespace a {
  var fn: typeof import("./other-file.d.ts").fn;
}

export { a };
// other-file.d.ts
export declare function fn(): void;

The .ts files are

// index.ts
import { fn } from "./other-file";
export function a() {}
a.fn = fn;
// other-file.ts
export function fn() {}

Output

declare function fn(): void;

declare function a(): void;
declare namespace a {
    var fn: typeof fn;
}

export { a };

You can see that var fn circularly references itself, rather than referencing the fn function.