Importing interface from vue component
See original GitHub issueHey,
I’m using ts-jest with vue-jest but I can’t import interfaces from the .vue component files. I’m getting this error:
Module '"*.vue"' has no exported member 'Option'.
Does vue-jest support exporting interfaces? or maybe it is not related with vue-jest. Anyway, I appreciate some guidance on that. Thanks
Issue Analytics
- State:
- Created 4 years ago
- Reactions:14
- Comments:10
Top Results From Across the Web
How to export an interface from a single vue component?
The answer was simple - add the .vue extension when importing.
Read more >Importing interface from a vue component does not work as ...
From ComponentB try importing as import {SomeInterface} from '@/components/ComponentA.vue';. What is the expected result? Interface should be able to import.
Read more >How To Use TypeScript with Vue Single File Components
This code imports the User interface and declares reactive data as type User . The computed property returns a string , so a...
Read more >TypeScript with Composition API - Vue.js
The interface or object literal type can contain references to types imported from other files, however, the generic argument itself passed to defineProps ......
Read more >Make the most of your Vue components with Typescript
Change the module definition with: <script lang="ts"> import Vue from 'vue';export default Vue.extend({ // ... You component (name, props, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this is the same issue, if not I can split into my own. While using jest + typescript I can’t import non-default exports from
.vue
files. Although, I have no issue doing this with other.ts
files while running my standard build. The following example would produce:TS2614: Module '"*.vue"' has no exported member 'IMyComponent'. Did you mean to use 'import IMyComponent from "*.vue"' instead?
mycomponent.vue:
mycomponent.spec.ts (compiles fine normal build, blows up when running jest):
someother.ts (compiles fine normal build):
Giving this a 2021 bump, I’m happy to help with the solution.