vuejs / language-tools

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

Type errors when using different vue versions in pnpm monorepo #4662

Closed ZWkang closed 1 month ago

ZWkang commented 1 month ago

Vue - Official extension or vue-tsc version

v2.0.28

VSCode version

1.92.0

Vue version

3.4.0/3.4.36

TypeScript version

^5.3.2

System Info

System:
    OS: macOS 14.2
    CPU: (8) arm64 Apple M1
    Memory: 101.55 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh

Steps to reproduce

Download the repo code. pnpm install. check my-vue-app/my-vue-app2 App.vue file difference.

What is expected?

expect my-vue-app App.vue htmlRef should be right.

What is actually happening?

htmlRef throw a type error.

Link to minimal reproduction

https://github.com/zwkang-dev/monorepo-vue-type-bug

Any additional comments?

my-vue-app using vue@3.4.0. my-vue-app using vue@3.4.36 how to support two version vue in a workspace monorepo project.

davidmatter commented 1 month ago

This has nothing to do with 2 different versions. The problem here is that Ref is typed differently in 3.4.0 and 3.4.36. The new one works, the old one does not.

3.4.36: Ref<UnwrapRef<T>, UnwrapRef<T> | T> 3.4.0: Ref<UnwrapRef<T>>

ZWkang commented 1 month ago

@davidmatter Thanks your reply. My another question is why my-vue-app type not use 3.4.0 Ref, using the latest 3.4.36 version. is monorepo setting problem or ?

davidmatter commented 1 month ago

In one package you have added vue@3.4.0 in the other vue@3.4.36. Just update your vue dependency

ZWkang commented 1 month ago

@davidmatter
In my case I need two directories to use different vue versions at the same time. do you have any suggestions?