vuejs / language-tools

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

feat(language-core): support `@vue-generic` #4971

Closed KazariEX closed 2 weeks ago

KazariEX commented 3 weeks ago

resolve vuejs/core#8015

pkg-pr-new[bot] commented 3 weeks ago

Open in Stackblitz

vue-component-meta

``` pnpm add https://pkg.pr.new/vuejs/language-tools/vue-component-meta@4971 ```

vue-component-type-helpers

``` pnpm add https://pkg.pr.new/vuejs/language-tools/vue-component-type-helpers@4971 ```

@vue/language-plugin-pug

``` pnpm add https://pkg.pr.new/vuejs/language-tools/@vue/language-plugin-pug@4971 ```

@vue/language-core

``` pnpm add https://pkg.pr.new/vuejs/language-tools/@vue/language-core@4971 ```

@vue/language-server

``` pnpm add https://pkg.pr.new/vuejs/language-tools/@vue/language-server@4971 ```

@vue/language-service

``` pnpm add https://pkg.pr.new/vuejs/language-tools/@vue/language-service@4971 ```

vue-tsc

``` pnpm add https://pkg.pr.new/vuejs/language-tools/vue-tsc@4971 ```

@vue/typescript-plugin

``` pnpm add https://pkg.pr.new/vuejs/language-tools/@vue/typescript-plugin@4971 ```

commit: 63c4f50

johnsoncodehk commented 2 weeks ago

I think writing types in v-generic is wrong in Vue's specification, according to the documentation custom directives only receive JS statements, the v-generic convention may break compatibility with other tools/libraries.

We should use generic, or convention to pass type parameters in HTML comment through <!-- @vue-generic {xxx} -->.

KazariEX commented 2 weeks ago

The runtime support for v-generic only requires the use of noopDirectiveTransform to skip the compile of this directive vuejs/core#12301, which should only cause the user's custom directive with the same name to become invalid.

johnsoncodehk commented 2 weeks ago

@KazariEX I see, but this will still break Vue versions prior to https://github.com/vuejs/core/pull/12301, especially since Vue 2 has stopped being maintained. Since this is a language tools specific feature, we need an implementation that doesn't have to change core.

KazariEX commented 2 weeks ago

Can we consider it as a feature of the next minor version?