I've been working on implementing a Vue directive in typescript, but I'm struggling to determine the correct types to use for the Vue install function.
Using install(Vue: any): void
feels a bit strange to me.
I attempted importing Vue and using install(Vue: Vue)
, but it resulted in an error stating that there is no .directive
property on Vue, which is confusing.
What should be the proper typing for the install function? Should the Vue
type work in this scenario? Am I missing something, or is there something lacking from the Vue
object?
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);
}
};