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 405 forks source link

v-for is not supported with useTemplateRef #4932

Closed quantix-dev closed 1 month ago

quantix-dev commented 1 month ago

Vue - Official extension or vue-tsc version

2.1.6

VSCode version

1.94.2

Vue version

3.5.12

TypeScript version

5.6.3

System Info

No response

package.json dependencies

No response

Steps to reproduce

  1. In a component template add any element with a v-for
  2. Add a ref and use useTemplateRef in the script tag
  3. The type will correctly infer for ONE single element but not account for the v-for

The vuejs docs provide an example of useTemplateRef with a v-for here which suffers from this issue.

What is expected?

The type should infer an array of the element if the ref is on a v-for to align with the vuejs behaviour https://vuejs.org/guide/essentials/template-refs.html#refs-inside-v-for

What is actually happening?

The type being inferred is only for one element of the referred element.

Link to minimal reproduction

No response

Any additional comments?

No response