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

vue.volar 2.1.X breaks SFC setup macros type inference in template #4751

Closed auirarrazaval closed 2 months ago

auirarrazaval commented 2 months ago

Vue - Official extension or vue-tsc version

2.1.X

VSCode version

1.92.2

Vue version

3.4.48

TypeScript version

5.5.4

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (16) x64 AMD Ryzen 9 5900HS with Radeon Graphics
    Memory: 4.67 GB / 7.76 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 4.3.1 - ~/.nvm/versions/node/v20.11.1/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm

Steps to reproduce

Once I updated the library's version to 2.1.X, all prop types defined in setup macros were not correctly inferred inside the template.

What is expected?

The following image is using v2.0.X, where the src prop type is correctly inferred as string | unknown, and JSDocs are also loaded

image

What is actually happening?

In the image below you can (left side) see how I use the defineProps<Type>() macros to define the props of my component, but on the template (right side) the type inference of the src prop is not inferred correctly image

Oddly enough, variables explicitly defined in the setup will be inferred correctly. So if I explicitly use the props, the types are loaded correctly: image

Link to minimal reproduction

repo

Any additional comments?

I have to admit that I tried reproducing a minimal reproduction with a fresh yearn create vite, but couldn't reproduce it. However, this issue is happening across all my projects, which use different vue, node, and vite versions. If needed I can try trimming down a project little by little until I find the combination of elements that's triggering the issue, but that would have to wait until the weekend

Thank you very much for all your help and time that goes into this 🙌


Update: upon further testing, I realized that the issue rises when I use yarn's nodeLinker: pnp, I have provided a link that fails. I just did a yarn create vite and changed yarn to pnp

KazariEX commented 2 months ago

I cannot reproduce on my machine, could you provide a minimal repro for it?

auirarrazaval commented 2 months ago

@KazariEX Will provide one during the weekend!

auirarrazaval commented 2 months ago

@KazariEX Actually I think i did identify correctly the issue: I updated the description above and provided a reproduction link

KazariEX commented 2 months ago

It seems that the repo does not exist.

auirarrazaval commented 2 months ago

My bad, now it should be public

WangJincheng4869 commented 2 months ago

我也遇到了差不多的问题,插件已经无法使用,只能回退 2.0.28

没有任何的提示信息,看上去插件没有生效。 图片

PDieE commented 2 months ago

same issue, so I returned version 2.0.28 ⬇️ 2.0.28 ⬇️ QQ_1724985021313

⬇️ 2.1.x ⬇️ QQ_1724985091639

codethief commented 2 months ago

Same issue here, downgrading the extension to 2.0.28 fixed it.