Skip to content

TypeScript got incorrect vue version with pnpm workspace #254

@SwingCosmic

Description

@SwingCosmic

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions