Currently, I am attempting to add type hints to my props within a Vue 3 component using the composition API.
This is my approach:
<script lang="ts">
import FlashInterface from '@/interfaces/FlashInterface';
import { ref } from 'vue';
import { useStore } from 'vuex';
export default {
props: {
message: {
type: FlashInterface,
required: true
}
},
setup(props): Record<string, unknown> {
// Stuff
}
};
The structure of my FlashInterface
is as follows:
export default interface FlashInterface {
level: string,
message: string,
id?: string
}
Despite working smoothly in other scenarios, I encountered an issue where I received this error:
ERROR in src/components/Flash.vue:20:10
TS2693: 'FlashInterface' only refers to a type, but is being used as a value here.
18 | props: {
19 | message: {
> 20 | type: FlashInterface,
| ^^^^^^^^^^^^^^
21 | required: true
22 | }
23 | },
I'm puzzled as to why TypeScript perceives this as a value rather than a type. Any ideas on what I might be overlooking?