vueuse / vue-demi

🎩 Creates Universal Library for Vue 2 & 3
MIT License
2.9k stars 149 forks source link

TypeScript got incorrect vue version with pnpm workspace #254

Open SwingCosmic opened 4 months ago

SwingCosmic commented 4 months ago

A workspace project with Vue CLI 5, default vue verison is vue2.7.

Run build:3 succeeded, run build:2 got compiler error TS7006. yarn workspace can pass build, but VSCode still shows errors.

pnpm: 8.6.2 nodejs: 16.20


* a src/index.ts
```typescript
import { Plugin } from "vue-demi";
export default {
  install(app, ...options) {
    // do something
  },
} as Plugin;
* output

error in src/index.ts:3:11

TS7006: Parameter 'app' implicitly has an 'any' type. 15 | 16 | export default {

17 | install(app, ...options) { | ^^^



And tsc says that `vue-demi` is located at `/node_modules/.pnpm/vue-demi@0.14.6_@vue+composition-api@0.1.0_vue@3.2.13/node_modules/vue-demi/lib/index`, but its own vue version is 3.2.13, not 2.7.16.

![image](https://github.com/vueuse/vue-demi/assets/20746516/008f417d-2733-4c6c-be66-2a3747299dbe)
SwingCosmic commented 4 months ago

There is an extra script to switch vueCompilerOptions.target before running these builds to make sure vue-loader can get correct vue version