question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing interface from vue component

See original GitHub issue

Hey,

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:open
  • Created 4 years ago
  • Reactions:14
  • Comments:10

github_iconTop GitHub Comments

7reactions
JordanMajdcommented, May 12, 2020

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:

<template>
...
</template>
<script lang="ts">
export interface IMyComponent extends Vue {
  ...
};
export default Vue.extend({
 ...
});
</script>

mycomponent.spec.ts (compiles fine normal build, blows up when running jest):

import MyComponent, { IMyComponent } from "../mycomponent.vue";

someother.ts (compiles fine normal build):

import MyComponent, { IMyComponent } from "../mycomponent.vue";
6reactions
JordanMajdcommented, Dec 1, 2021

Giving this a 2021 bump, I’m happy to help with the solution.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found