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:
What can I do to import the interface successfully?
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.
The recommendation is to use composables when reusing pure logic, and use components when reusing both logic and visual layout.
Using export default: You can use export-default for creating local registration for the Vue component.
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.
You can drop the { } from your import. It’s a default export, so then you write import IBasic from "@/../containers/Basic"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With