-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
No matching export for import typescript interface #2117
Comments
I have the same problems tonight. But one day before, it works fine!!! I didn`t update any dependency! |
This is because the imported TypeScript type exists in the export statement, which should normally be type-erased. You can avoid passing TypeScript types by importing them directly in the desired file. |
I can run it in parcel, and export type interface is common in project. We shouldn't avoid it. Vite should process it corrrectly like parcel. |
I think |
Yes, i know it is a correct behavior. I mean the better way is not to re-export the Typescript interface. If you have to write it this way, please use |
And maybe we should do some warning for this way? @yyx990803 |
I got it. Yes you are right, export type just one time is correct in vite. But I am used to create a folder named |
This is a wontfix because esbuild transforms files in isolation. If you really want this behavior you need to disable esbuild and use something like @rollup/plugin-typescript. |
But what about tsx? |
I wonder the best way that you mean. Thanks. |
I have the same issue. What is the correct way of defining/exporting/importing interfaces @yyx990803? |
@pingustar |
Do not re-export interface in vite. You can just export it in file A and import it in file B. Don`t try to export it in file B again. |
Sorry, for asking again... I seem to do something wrong. I have a export type User = {
name: string
age: number
} and in my component <script setup lang="ts">
import { ref } from 'vue'
import { User } from '~/types'
const users = ref<User[]>([])
</script> Which results in the following error logged to the browser console:
What am I missing? |
There is a know issue in Vue with type imports, it should work if you use the
@pingustar let's avoid commenting on old issues, your question may end up being ignored. Please start a GitHub Discussion or join the chat at Vite Land to ask questions. |
b.js
|
I had this error when a variable was named as an interface |
I had this issue with an interface named |
Describe the bug
Uncaught SyntaxError: The requested module '/app.ts' does not provide an export named 'Test'
Reproduction
https://github.com/lake2/vite_bug
System Info
vite
version: 2The text was updated successfully, but these errors were encountered: