Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

export of interface from package results in error #109

Closed
maciejw opened this issue Feb 7, 2018 · 10 comments
Closed

export of interface from package results in error #109

maciejw opened this issue Feb 7, 2018 · 10 comments

Comments

@maciejw
Copy link

maciejw commented Feb 7, 2018

I have a ts module that exports an interface and then I reexport it in index.ts as a public contract for ts users.

I think that rollup expects that exported type is a class or function, type that is emitted to js also.

[!] Error: 'InterfaceXXX' is not exported by src\types.ts
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module

this code works fine when I transpile it using tsc.

is my diagnose correct?

@karak
Copy link

karak commented Apr 17, 2018

I have also got those errors and others.
Finally, rollup-plugin-typescript2 works for me.

@aldo-roman
Copy link

any updates on this issue? seems blocking when trying to adopt rollup

@alvarolorentedev
Copy link

yes...this is giving us a big headache :( . Any ideas on how to work around it?

@aldo-roman
Copy link

I gave up and now compile typescript on a separate step using tsc directly. Then rollup to bundle the resulting javascript.

@yacinehmito
Copy link

I am experiencing the same issue. (I'm using rollup-plugin-typescript v.1.0.0)

@gilamran
Copy link

This makes rollup and typescript unusable for libraries who want to publish type definitions...

@aleclarson
Copy link

aleclarson commented Jun 1, 2019

I don't use this plugin, but I'm seeing the same kind of error using Babel to transpile my TypeScript code before bundling it with Rollup. It seems that Rollup is parsing the exports before the types are stripped.

edit: According to this comment, Babel works on a per-module basis, so it can't properly remove re-exported types.

@slavafomin
Copy link

slavafomin commented Jun 14, 2019

We have exactly the same issue with types re-exporting. This problem makes this plugin unusable for any serious TypeScript library.

--

Phew, the rollup-plugin-typescript2 saved my day as well!

@mbrowne
Copy link

mbrowne commented Jul 11, 2019

Following up on @aleclarson's comment, it seems that if you have the following requirements:

  • build using rollup (obviously)
  • export interfaces from your package
  • use Babel plugins on your TypeScript code

...then currently the only solution seems to be to use both the rollup-plugin-typescript2 plugin and the babel plugin, e.g.:

    typescript(),
    babel({ extensions: ['.ts', '.tsx'], include: ['src/**/*'] }),

@shellscape
Copy link
Contributor

Hey folks (this is a canned reply, but we mean it!). Thanks to everyone who participated in this issue. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and we have to do some spring cleaning of the issues to make that happen. We're going to close this one, but it doesn't mean that it's not still valid. We've got some time yet before the move while we resolve pending Pull Requests, so if this issue is still relevant, please @ me and I'll make sure it gets transferred to the new repo. 🍺

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

No branches or pull requests

10 participants