-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Unable to re-export imported interfaces #1990
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
Comments
|
You are exporting This has nothing to do with Vue CLI. |
@yyx990803 I've searched far & wide on how to import an interface and re-export is, and found nothing. I assumed it was a Vue CLI issue since VS Code shows no warnings, and there are no TypeScript errors or TSLint issues either. What is the correct way to import/re-export interfaces and types? |
If you export an interface but not use it, TypeScript cannot safely remove the interface from emitted code. Exporting it from |
You're right, once I didn't export from But then I don't understand why this code (my actual code) fails:
src/store/modules/auth/index.tsexport interface AuthState {
email: string | null;
firstName: string | null;
lastName: string | null;
loggingIn: boolean;
loggingOut: boolean;
orgId: number | null;
orgName: string | null;
refreshToken: string | null;
token: string | null;
userId: string | null;
[key: string]: any;
}
// ...
export default module; src/store/index.tsimport auth, { AuthState } from './modules/auth';
// ...
export { AuthState };
export default store; src/views/TagList.vue<script lang="ts">
import Vue from 'vue';
import { AuthState } from '@/store';
// ... If this is not a Vue issue, maybe you could tell me the proper place to report this, because it definitely seems like a bug somewhere in the chain. |
@yyx990803 There are some serious bugs in Vue + TypeScript. Here's another one: There's a reproduction repo in there. Try it out, and you'll see that the thrown Jest error makes no sense. I created a plain JS project and used the exact same code (minus the TS annotations of course), and the test ran fine. I have a feeling this is an edge case, related to this issue with re-importing types. If this is a Vue bug, let me know and I'll re-file this issue under the Vue repo. |
@sodatea Thank you, that fixed it! |
@sodatea Though, changing this setting introduced new errors:
Synthetic imports was addressing this. Do I now have to do |
|
@ffxsam |
It was a bug in the TS documentation: microsoft/TypeScript-Handbook@8e974c8 So |
Version
3.0.0-rc.9
Node and OS info
Node 8.10.0, Yarn 1.7.0, macOS 10.13.6
Steps to reproduce
Reproduction: https://github.com/ffxsam/repro-reexport-warning
Export an interface from file A, import it into file B, then re-export it from file B.
What is expected?
It should work with no warnings or errors.
What is actually happening?
Warnings are thrown.
The text was updated successfully, but these errors were encountered: