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

error TS2688: Cannot find type definition file for '.vue-global-types/vue_3.5_false.d.ts' #4963

Closed Mivik closed 3 weeks ago

Mivik commented 3 weeks ago

Vue - Official extension or vue-tsc version

2.1.8

VSCode version

1.94.2

Vue version

3.5.12

TypeScript version

5.4.5

System Info

System:
    OS: Linux 6.11 Arch Linux
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 22.45 GB / 31.04 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 20.18.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 10.9.0 - /usr/bin/npm
    bun: 1.1.33 - ~/.bun/bin/bun

package.json dependencies

{
  "dependencies": {
    "pinia": "^2.2.4",
    "vue": "^3.5.12",
    "vue-router": "^4.4.5"
  },
  "devDependencies": {
    "@rushstack/eslint-patch": "^1.10.4",
    "@tsconfig/node20": "^20.1.4",
    "@types/node": "^20.17.1",
    "@vitejs/plugin-vue": "^5.1.4",
    "@vue/eslint-config-prettier": "^9.0.0",
    "@vue/eslint-config-typescript": "^13.0.0",
    "@vue/tsconfig": "^0.5.1",
    "eslint": "^8.57.1",
    "eslint-plugin-vue": "^9.29.1",
    "npm-run-all2": "^6.2.6",
    "prettier": "^3.3.3",
    "typescript": "~5.4.5",
    "vite": "^5.4.10",
    "vue-tsc": "^2.1.8"
  }
}

Steps to reproduce

Use vue-tsc 2.1.8 and type-check the project

What is expected?

type-check should run without errors

What is actually happening?

type-check failed with

error TS2688: Cannot find type definition file for '/path/to/project/node_modules/.vue-global-types/vue_3.5_false.d.ts'.

30 /// <reference types="/path/to/project/node_modules/.vue-global-types/vue_3.5_false.d.ts" />

See https://github.com/vuejs/language-tools/pull/4924#issuecomment-2439996063

Link to minimal reproduction

https://github.com/Mivik/vue-lang-tool-reproduce

Any additional comments?

This issue was said to be fixed in https://github.com/vuejs/language-tools/pull/4924, however this PR introduced the very same problem for me. Using vue-tsc 2.1.6 does not yield this error.

johnsoncodehk commented 3 weeks ago

Does the /path/to/project/node_modules/.vue-global-types/vue_3.5_false.d.ts file exist on your file system? If yes, you can reproduce the error by writing /// <reference types="/path/to/project/node_modules/.vue-global-types/vue_3.5_false.d.ts" /> in any .ts file?

Mivik commented 3 weeks ago

Okay, I narrowed down the issue. The path got automatically lowercased which causes the issue to happen only if the project path contains uppercase letters.

src/App.vue:8:23 - error TS2688: Cannot find type definition file for '/home/mivik/test/repro/node_modules/.vue-global-types/vue_3.5_false.d.ts'.

8 /// <reference types="/home/mivik/Test/repro/node_modules/.vue-global-types/vue_3.5_false.d.ts" />
johnsoncodehk commented 3 weeks ago

Did you mean /// <reference types="/home/mivik/Test/repro/node_modules/.vue-global-types/vue_3.5_false.d.ts" /> case is correct, but somehow when type checking it converted to lowercase?

What is the typescript version in your node_modules? Will upgrading to the latest version solve the problem?

johnsoncodehk commented 3 weeks ago

@Mivik can you help us remotely investigate this issue?

https://github.com/vuejs/language-tools/wiki/Help-Us-Investigate-Issues-Remotely

Mivik commented 3 weeks ago

Did you mean /// <reference types="/home/mivik/Test/repro/node_modules/.vue-global-types/vue_3.5_false.d.ts" /> case is correct, but somehow when type checking it converted to lowercase?

What is the typescript version in your node_modules? Will upgrading to the latest version solve the problem?

Yes the path exists and it's converted to lowercase during type checking

Typescript version is 5.4.5.

BTW I think probably check #4924 since using absolute path for global types fixes a specific issue and switching back to relative path might break that promise.

KazariEX commented 3 weeks ago

This is due to the issue of inconsistent path resolving behavior caused by older versions of Typescript, which can result in incorrect lowercase path name in case sensitive systems.

NicolasPL64 commented 3 weeks ago

This is due to the issue of inconsistent path resolving behavior caused by older versions of Typescript, which can result in incorrect lowercase path name in case sensitive systems.

So the solution is...? (also, is there any workaround for now?)

KazariEX commented 3 weeks ago

The fix has been released.