Reputation: 717
And I've made a global component Icon because it's used almost everywhere so i can just type it without importing the component. Problem is that VSCode think it's some mistake (without import).
The component works good. It's imported to vue app in main.ts like this:
// registration of global component <Icon />
import IconComponent from './components/ui/icon/IconComponent.vue'
app.component('Icon', IconComponent)
Any idea how could I tell VSCode "hey this is a global component, so don't mark it as mistake in other .vue files"? :)
Upvotes: 2
Views: 3600
Reputation: 717
On Volar github there is:
"Local components, Built-in components, native HTML elements Type-Checking is available with no configuration. For Global components, you need to define GlobalComponents interface, for example:"
// components.d.ts
// declare module '@vue/runtime-core' works for vue 3
// declare module 'vue' works for vue2 + vue 3
declare module 'vue' {
export interface GlobalComponents {
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}
}
export {}
Upvotes: 5