Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue / Typescript, got Module '"*.vue"' has no exported member

I want to export several interfaces together with Component from .vue file.

Basic.vue:

<template>
    <div class="app">
        <router-view></router-view>
    </div>
</template>

<script lang="ts">
import { Vue, Component } from "vue-property-decorator";

export interface IBasic {
    name :string;
}

/**
 * Simplest container
 */
@Component
export class Basic extends Vue {}
export default Basic;
</script>

But when I import it from another .ts file, I got:

enter image description here

What can I do to import the interface successfully?

like image 687
Val Avatar asked May 14 '19 09:05

Val


People also ask

Has no exported member define component?

The error "Module has no exported member" occurs when we try to import a member that doesn't exist in the specified module. To solve the error, make sure the module exports the specific member and you haven't mistyped the name or mistaken named for default import.

When to use composables?

The recommendation is to use composables when reusing pure logic, and use components when reusing both logic and visual layout.

What is Vue export default?

Using export default: You can use export-default for creating local registration for the Vue component.


3 Answers

You can try to use ktsn/vuetype than will generate custom declaration file for every your component file, instead of using default shims-vue.d.ts declaration.

like image 33
SergeyK Avatar answered Oct 05 '22 21:10

SergeyK


You can drop the { } from your import. It’s a default export, so then you write import IBasic from "@/../containers/Basic"

like image 189
Diego Araújo Avatar answered Sep 16 '22 16:09

Diego Araújo


I had this same problem and realize that despite of no having errors on my IDE, the error was still thrown so I just Restart the server and it works perfectly... I have to do this every time I created a import or export anything with TS.

like image 27
Daniel Coglitore Avatar answered Oct 05 '22 22:10

Daniel Coglitore