vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.86k stars 400 forks source link

Completion for global directives #4988

Open benedictleejh opened 1 week ago

benedictleejh commented 1 week ago

What problem does this feature solve?

vuejs/core#3399 has landed in Vue 3.5, and the GlobalDirectives interface exists, but Volar does not seem to populate directive completions from the the GlobalDirectives interface.

On a fresh project created with pnpm create vue@latest, with VSCode, adding the module declaration

declare module 'vue' {
  interface GlobalDirectives{
    vHelloWorld: any;
  }
}

(in App.vue) enables type hints and jump to definition (at least to the module declaration) on the directive in Vue SFCs, but the completion popup when attempting to use the directive does not include v-hello-world.

I only managed to make the directive completion work when doing

declare module 'vue' {
  interface ComponentCustomProperties {
    vHelloWorld: any;
  }
}

What does the proposed solution look like?

Volar should provide completion for global directives declared in the GlobalDirectives interface.

KazariEX commented 1 week ago

Do you mean that only completion does not take effect? Can you jump to the type definition through F12 after completely typing the directives?

benedictleejh commented 1 week ago

Yes, it's only completion that doesn't work. The jump to the type definition (whether ctrl+click or F12) works.