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

type only exports of classes are not respected #311

Open
3 tasks done
brc-dd opened this issue Jun 4, 2024 · 3 comments
Open
3 tasks done

type only exports of classes are not respected #311

brc-dd opened this issue Jun 4, 2024 · 3 comments

Comments

@brc-dd
Copy link
Contributor

brc-dd commented Jun 4, 2024

Checklist

  • I can reproduce this issue when running this plugin on its own.
    Other plugins, such as node-resolve are known to cause issues.
  • I am running this plugin on .d.ts files generated by TypeScript.
    The plugin can consume .ts and even .js files (with allowJs: true), but this is known to cause issues.
  • This issue is not related to rolling up @types.
    The plugin ignores these by default, unless respectExternal is set. @types can contain hand-crafted code which is known to cause issues.

Code Snippet

declare class Foo {
  bar: string;
}

export type { Foo };

Actual Output

declare class Foo {
  bar: string;
}
export { Foo };

Expected Output

declare class Foo {
  bar: string;
}
export type { Foo };

Additional Context

It works if I alias my class as a type instead:

declare class _Foo {
  bar: string;
}

type Foo = _Foo;

export type { Foo };

Output

declare class _Foo {
  bar: string;
}
type Foo = _Foo;
export type { Foo };
@GeekyEggo
Copy link

Hey @brc-dd, did you ever find a solution to this issue?

@brc-dd
Copy link
Contributor Author

brc-dd commented Sep 24, 2024

Ah, no. I was debugging it but it didn't pan out. I end up just patching the types package that was breaking stuff for me.

@GeekyEggo
Copy link

Ah, no. I was debugging it but it didn't pan out. I end up just patching the types package that was breaking stuff for me.

No sweat, that was my first thought too, leveraging something like ts-morph. I'm also debating outputting the raw DTS files from TSC, and then updating the current rollup'd DTS file to export * from there as they're correct. Appreciate your quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants