Plugins: Error: [type] is not exported by [file]

Created on 15 Nov 2019  ·  18Comments  ·  Source: rollup/plugins

_(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?

s² 🔥🔥 important t¹ 🐞 bug 🔌 plugin-typescript

Most helpful comment

I'll try to get this working with our larger TS plugin updates.

All 18 comments

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. :beer:

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.

Hi, is this fixed or not?

It's not fixed yet, it's just been transferred to the new repository.

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

import { Type1, Type2 } from './file.ts';

export {
    Type2
}

export const fn1: Type1 = () => {
    // ...
}

I just

import { Type1, Type2 } from './file';

export const fn1: Type1 = () => {
    // ...
}

export * from './file';

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.

I just realized that this is a duplicate of https://github.com/rollup/rollup-plugin-typescript/issues/28. Sorry for the inconvenience.

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-typescript2 handles this situation very well but it is really slow after upgrading to typescript 3.4.

@ziofat if you'd like to put together a minimal reproduction in a repo that we can clone, I'd be happy to reopen this. We're going to need a reproduction to triage this.

@shellscape OK, I will try to make a reproduction later.

I created a repo that reproduces the issue here https://github.com/PeteJodo/repro-rollup-typescript-export-type-issue

I get this output

> [email protected] rollup /Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue
> rollup -c


src/index.ts → dist/index.js...
[!] Error: 'IExample' is not exported by src/dep.ts
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
src/index.ts (1:9)
1: export { IExample, MyExample } from './dep';
            ^
Error: 'IExample' is not exported by src/dep.ts
    at error (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:5365:30)
    at Module.error (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:9708:9)
    at handleMissingExport (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:9625:21)
    at Module.getVariableForExportName (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:9829:17)
    at Module.includeAllExports (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:9876:35)
    at Promise.all.then (/Users/pjodogne/Projects/TEMP/repro-rollup-typescript-export-type-issue/node_modules/rollup/dist/rollup.js:13083:24)
    at <anonymous>

Yes, I have the same issue and temporary not exporting the props of my React components due to this issue. I have also tried rollup-plugin-typescript2 but that's not working at all, keep getting failed to transpile '/Users/work/experiment/src/index.ts' and have no idea what that is supposed to mean.

@NotWoods this might be up your alley. @PeteJodo put together a reproduction repo for reference, and it might be related to the updates you have planned already.

I'll try to get this working with our larger TS plugin updates.

This is fixed with @rollup/plugin-typescript version 3.0.0!

@rollup/plugin-typescript
Hi, congrats to fix this bug 🎉.
When the new version will be released?

Can we reopen? I'm still receiving this error when using Babel to compile TypeScript and importing types from third-party libs in node_modules when those types are exported in the library code using the same pattern that @Vehmloewff described above. (Example: import { GraphQLSchema } from 'graphql'.)

@earksiinni you're welcome to open a new issue with a proper reproduction. We won't be reopening this one.

Solved this issue by doing the following:
index.ts

import { TypeYouWantToExport as TypeYouWantToExportReal } from './file1'

export type TypeYouWantToExport = TypeYouWantToExportReal
Was this page helpful?
0 / 5 - 0 ratings