plugins: Error: [type] is not exported by [file]
(This issue was transferred from rollup-plugin-typescript and had no issue template)
This code:
import { Type1, Type2 } from './file.ts';
export {
Type2
}
export const fn1: Type1 = () => {
// ...
}
Throws this error in the console:
[!] Error: 'Type2' is not exported by src/file.ts
Is there any workaround or fix for this?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 29 (7 by maintainers)
For desperate googlers: I’m a total rollup/typescript noob but I fixed it for myself with
https://www.typescriptlang.org/docs/handbook/modules.html#importing-types
Can we reopen? I’m still receiving this error when using Babel to compile TypeScript and importing types from third-party libs in
node_moduleswhen those types are exported in the library code using the same pattern that @Vehmloewff described above. (Example:import { GraphQLSchema } from 'graphql'.)In my case I was importing an
enumsoimport typewas preventing it from being used as a value. Specifying that the module that I’m importing from should remain external to the bundle invite.config.jsresolved the issue:this worked for me!
I’ll try to get this working with our larger TS plugin updates.
I ran into this issue when trying to use an enum that was exported by the library’s typedef but which wasn’t exported in the library’s es6 module. There was no help from the compiler until switching from
import { Blah } from "blah"toimport type { Blah } from "blah". Then the compiler barfed up the problem. I worked around the problem by just using the raw string, but there might be a magic sequence of tsconfig that would have helped.Having same issue when I build in Vite. All my interfaces get the import/export error
This is fixed with @rollup/plugin-typescript version 3.0.0!
Well. You are referring to a issue in old repository and it was closed due to repository move. However this is not resolved right now. For me the workaround is not acceptable because I have a very large code base. The
rollup-plugin-typescript2handles this situation very well but it is really slow after upgrading to typescript 3.4.This worked for me too (import type) but it does seem like a workaround.
There is a workaround for this, I’ll be it is not an ideal one, but it is what I have been using in the meantime.
Instead of
I just
The only problem with this is that I do not really want to export
Type1. But in my case, I would rather have extra export that not have the ones I need.Thanks for responding!
I think that this issue is still relevant @shellscape. I would be glad to know that it will be transferred to the new repo.