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

``$attrs`` or ``ReturnType<typeof useAttrs()>`` is always ``Data``when ``fallthroughAttributes: true`` #5008

Open ferferga opened 6 days ago

ferferga commented 6 days ago

Vue - Official extension or vue-tsc version

2.1.10

VSCode version

1.95.3

Vue version

3.5.12

TypeScript version

5.6.3

System Info

No response

package.json dependencies

"dependencies": {
  "vue": "3.5.12"
},
"devDependencies": {
  "@types/node": "22.9.0",
  "@vitejs/plugin-vue": "5.2.0",
  "typescript": "5.6.3",
  "vite": "5.4.11",
  "vue-tsc": "2.1.10"
}

Steps to reproduce

  1. Open the plaground link
  2. Hover over attrs: the type will be Data instead of ButtonHTMLAttributes
    const attrs = useAttrs();
  3. Run npm run check: You will see that

What is expected?

The type of the fallthrough attributes should be Data when there is no v-bind="$attrs" assigned to an element. But when it is assigned, it should be of the assigned element's attributes type.

What is actually happening?

The type of the fallthrough attributes always is Data, both on useAttrs and $attrs.

Link to minimal reproduction

https://stackblitz.com/edit/vue3-vite-typescript-starter-aahszk?file=src%2Fcomponents%2FVButton.vue

Any additional comments?

No response