Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript got incorrect vue version with pnpm workspace #254

Open
SwingCosmic opened this issue Feb 22, 2024 · 1 comment
Open

TypeScript got incorrect vue version with pnpm workspace #254

SwingCosmic opened this issue Feb 22, 2024 · 1 comment

Comments

@SwingCosmic
Copy link

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

  • project structure
-- packages
     |-- a
     |-- b 
  • a package.json
{
  "scripts": {
    "build:2": "vue-demi-switch 2.7 && pnpm run build",
    "build:3": "vue-demi-switch 3 vue3 && pnpm run build",
    "build": "vue-cli-service build"
  },
  "devDependencies": {
    // ... other dependencies
    "vue": "^2.7.16",
    "vue-tsc": "^1.8.25",
    "vue3": "npm:vue@^3.2.13",
    "vue-demi": "^0.14.6"
  }
  // ...
}
  • a src/index.ts
import { Plugin } from "vue-demi";
export default {
  install(app, ...options) {
    // do something
  },
} as Plugin;
  • b package.json
{
  "scripts": {
    "build": "vue-cli-service build"
  },
  "devDependencies": {
    // ... other dependencies
    "vue": "^3.2.13",
    "vue-demi": "^0.14.6",
    "a": "*"
  }
  // ...
}
  • 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/[email protected]_@[email protected][email protected]/node_modules/vue-demi/lib/index, but its own vue version is 3.2.13, not 2.7.16.

image

@SwingCosmic
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant