language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

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

Open Jibacat opened this issue 1 year ago • 7 comments

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

Jibacat avatar Jul 01 '24 09:07 Jibacat

I have the same issue with Nuxt 3.11.2 and Typescript 5.4.5

TerrorSquad avatar Jul 01 '24 14:07 TerrorSquad

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

erwanjugand avatar Jul 01 '24 15:07 erwanjugand

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

zziilii avatar Jul 02 '24 06:07 zziilii

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.

TerrorSquad avatar Jul 02 '24 09:07 TerrorSquad

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

Jibacat avatar Jul 03 '24 06:07 Jibacat

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

Kanade-Lu avatar Jul 05 '24 03:07 Kanade-Lu

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

True

GabrielHangor avatar Jul 09 '24 08:07 GabrielHangor