vuejs / language-tools

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

Vue2 <template> get "any" type when using custom component #4518

Open Jibacat opened 6 days ago

Jibacat commented 6 days ago

Vue - Official extension or vue-tsc version

2.0.24

VSCode version

1.90.2

Vue version

2.7.10

TypeScript version

5.4.5

System Info

System:
    OS: macOS 12.7.3
    CPU: (8) x64 Apple M2
    Memory: 26.81 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.21.3 - /usr/local/bin/node
    npm: 6.14.18 - /usr/local/bin/npm
  Browsers:
    Chrome: 126.0.6478.127
    Safari: 15.6.1

Steps to reproduce

image image image

I get "any" type on custom component "HelloWorld" in template.

How can I get exact type instead of "any"?

Link to minimal reproduction

No response

Any additional comments?

No response

TerrorSquad commented 6 days ago

I have the same issue with Nuxt 3.11.2 and Typescript 5.4.5

erwanjugand commented 6 days ago

Same issue with Nuxt 2, disable hybrid mode fixes the problem

zziilii commented 5 days ago

I have the same issue, I've been waiting for this feature for a long time, praying for it

TerrorSquad commented 5 days ago

Same issue with Nuxt 2, disable hybrid mode fixes the problem

This worked for me. Also, setting the hybrid mode to typescriptPluginOnly also worked.

So, the workaround for now is to set the setting vue.server.hybridMode to either typescriptPluginOnly or false.

Jibacat commented 4 days ago

I try to disable hybrid mode, but it seems not working for me.

Kanade-Lu commented 2 days ago

this issue seems use vue-property-decorator problem,if you use setup model with ts, type will work as expected.