rollup/rollup-plugin-typescript

export of interface from package results in error

maciejw opened this issue ยท 10 comments

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 commented

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

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

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

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

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

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

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.

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!

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/**/*'] }),

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. ๐Ÿบ