Swatinem / rollup-plugin-dts

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

Invalid exports when using isolatedModules: true #276

Closed mithodin closed 1 year ago

mithodin commented 1 year ago

Checklist

Issue Description

When creating files using the tsconfig setting isolatedModules: true, type exports must explicitly use export type { ... } or export { type ... } (TS1205 is the relevant error code). tsc does this correctly, e.g. the following code snippet:

type Test = {
    challenge: string;
}
export { type Test };

is reproduced as-is in the corresponding .d.ts file. However, rollup-plugin-dts elides the type part of the export, leading to the mentioned error. A minimal reproduction can be found here: https://github.com/mithodin/dts-bundle-isolation-repro Compile using npm install && npm run build and check the file /dist/bundle.d.ts. For comparison with tsc, run npx tsc and check /out/gameLibrary.d.ts.

It should be mentioned that this causes issues for anyone using a library bundled using rollup-plugin-dts, who wants to enable isolatedModules.

mithodin commented 1 year ago

The problem persists with version 5.3.1., I have updated my example repo: https://github.com/mithodin/dts-bundle-isolation-repro

Swatinem commented 1 year ago

I was trying to bulk-close all of the old issues in the repo, as I have moved the project into maintenance mode: https://github.com/Swatinem/rollup-plugin-dts/issues/277 Too bad github does not allow bulk-close-with-comment.

That being said, I will most likely not work on resolving this issue, but would very much appreciate a PR.

Solving this would likely involve changing the "post processing" code to split type-only exports from normal exports.