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

Declaration types are missing when re-export default multiple times #109

Closed
sedx opened this issue Aug 11, 2020 · 5 comments
Closed

Declaration types are missing when re-export default multiple times #109

sedx opened this issue Aug 11, 2020 · 5 comments
Labels
Bug Something isn't working

Comments

@sedx
Copy link

sedx commented Aug 11, 2020

Hi! First of all thanks for plugin that can bundle d.ts too! It's killer feature, realy!

But I faced some issue, traditionally details below


  • Version: 1.3.2
  • Rollup Version: 2.23.1
  • Operating System and version (if applicable): macOS
  • Node Version (if applicable): v12.13.1
  • Does it work with tsc (if applicable): N/A

Reproduction

I have package that contains some sub modules (each submodule is separate entry point). Entry point has named exports View and Model (like this)

I placed Views and Models to sub folders and re-export default up-to submodule entry point.

When I build package I get broken type definition. View exported with type typeof default, but default is not defined 😔

Looks like reason is chain of export { default } from './someSourceFile'.

When I used named export all is fine. (here is result for named exports)

Repo with bug reproduction https://github.com/sedx/rollup-ts-bug
I added result of build to repo.

Expected Behavior

declare const _default: {
    foo: string;
    baz: number;
};
declare const Model: typeof _default;
declare const View: typeof MainView(): JSX.Element;
export { Model, View };
//# sourceMappingURL=A.d.ts.map

Actual Behavior

declare const _default: {
    foo: string;
    baz: number;
};
declare const Model: typeof _default;
// ⚠️ default here is not defined
declare const View: typeof default;
export { Model, View };
//# sourceMappingURL=A.d.ts.map
@wessberg wessberg added the Bug Something isn't working label Aug 12, 2020
@wessberg
Copy link
Owner

Hey there.
It took me a few years apparently, but this bug has been fixed now and will be part of v2.0.6 when it releases soon.

@diego-toro
Copy link

diego-toro commented Apr 15, 2022

hi @wessberg! Is it related to a weird behaviour I saw recently #176? By using re-exports, the resulting d.ts file doesn't resolve the inner types correctly.
Is there a way for me to install the v2.0.6? I tried npm i rollup-plugin-ts@next but didn't resolve a version

Update: Just cloned and locally installed. Seems to work fine.

@wessberg
Copy link
Owner

It is, yes. Your issue is covered by the fix too. It will be released shortly

@diego-toro
Copy link

That's Awesome! Thanks @wessberg

@wessberg
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants