I'm working in typescripting my vue directive, but I just cannot seem to find what types should i use for Vue install function.
Going with install(Vue: any): void
seems a little bit odd.
Ive tried importing Vue and then using install(Vue: Vue)
, but that throws out an error that there is no .directive
on Vue, which is also odd.
How should I type install function? Does Vue
type suppose to work here? What am I missing here, or does Vue
misses something?
import { DirectiveOptions } from "vue"
const directive: DirectiveOptions = {
bind(elem, bind, vn) {
console.log('bound')
}
};
export default {
install(Vue: any): void { // what types should be used here?
Vue.directive("do-stuff", directive);
}
};
The type you want is
VueConstructor
. Here's how a Typescript Vue plugin should be authoredSee https://github.com/vuejs/vue/blob/dev/types/vue.d.ts#L80