[Vuejs]-How can I add type hints for my custom global Vue directives?

0👍

According to the vue-language issue 465, currently I can declare the Directives in ComponentCustomProperties for global register directives but it may pollution component global properties.

// shim-vue.d.ts
import vFocus from 'my-custom-component-library'

declare module '@vue/runtime-core' {
    export interface ComponentCustomProperties {
        vFocus: typeof vFocus;
    }
}

export { }

Leave a comment