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

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

Open
spacedawwwg opened this issue Sep 20, 2024 · 7 comments · May be fixed by #4924
Open

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

spacedawwwg opened this issue Sep 20, 2024 · 7 comments · May be fixed by #4924
Labels
bug Something isn't working 🔨 p3-minor-bug

Comments

@spacedawwwg
Copy link

Vue - Official extension or vue-tsc version

2.1.6

VSCode version

1.93.1

Vue version

3.5.6

TypeScript version

5.3.3

System Info

System:
    OS: macOS 15.0
    CPU: (10) arm64 Apple M1 Max
    Memory: 6.98 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.1 - /usr/local/bin/node
    npm: 10.7.0 - /usr/local/bin/npm
    pnpm: 9.10.0 - /usr/local/bin/pnpm
    bun: 1.0.13 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 114.1.52.122
    Chrome: 128.0.6613.138
    Safari: 18.0

package.json dependencies

No response

Steps to reproduce

We're using a PNPM monorepo, each package has it's own type check. We run the these using Turborepo. The issue still happens randomly even type checking individual packages.

We're also using typescript references.

What is expected?

.vue-global-types/vue_3.5_false.d.ts is found

What is actually happening?

.vue-global-types/vue_3.5_false.d.ts is not found

Link to minimal reproduction

No response

Any additional comments?

We've tried adding

"plugins": [{ "name": "@vue/typescript-plugin" }],

directly to the tsconfig's and also tried adding

"paths": {
  "vue/__globalTypes_3.5_false": ["node_modules/vue/__globalTypes_3.5_false.d.ts"]
},

This didn't seem to help

@KazariEX
Copy link
Collaborator

.vue-global-types/vue_3.5_false.d.ts should exist directly in node_modules.

@Logima
Copy link

Logima commented Sep 20, 2024

I have a similar problem, which might be related. In a PNPM monorepo I have one library and an app. The app includes some library files using relative paths, like ../../library/src/somefile.vue.

.vue-global-types/vue_3.5_false.d.ts is created inside app/node_modules, but not for the library or the repo root, which causes this error for files imported from library. I've previously used vue-tsc 1.8.27, which worked fine with this setup.

I tried to fiddle with vite-plugin-checker's vueTsc root/tsconfigPath options, but couldn't get the file to be generated to repo root node_modules.

@KazariEX KazariEX added bug Something isn't working 🔨 p3-minor-bug and removed need info labels Sep 20, 2024
@trydofor
Copy link

pnpm + monorepo, vue-tsc check UnoIcon.vue Error at .pnpm/@unocss

 ERROR(vue-tsc)  Cannot find type definition file for '.vue-global-types/vue_3.5_false.d.ts'.
 FILE  /Volumes/...../node_modules/.pnpm/@[email protected][email protected][email protected][email protected][email protected][email protected][email protected]_/node_modules/@unocss/nuxt/runtime/UnoIcon.vue:4:23

    2 |   <div />
    3 | </template>
  > 4 | /// <reference types=".vue-global-types/vue_3.5_false.d.ts" />

@Alex-D
Copy link

Alex-D commented Sep 26, 2024

My workaround was to not point on the other package via relative path but via node modules mananged by pnpm.

So I've replaced:
../../packages/my-package
by
node_modules/@company/my-package

in my TypeScript alias

@trydofor
Copy link

trydofor commented Sep 26, 2024

in my case, i downgrade the pnpm as follows,
but i am not sure if it is all pnpm reson,

  • ✅ pnpm 9.9.0 + shared-workspace-lockfile=false
  • ❌ pnpm 9.10.0
  • ❌ pnpm 9.11.0

and, when using workspace:* protocol,
e.g. monorepo front deps on "common":"workspace:*",

sometimes, in front project, regenerate .nuxt will no error :P

rm -rf .nuxt
pnpm dev

@depressedX
Copy link

same problem in pnpm monorepo.

Error happens when trying import .vue file in another package.

For example, when executing vue-tsc in /apps/my-app, it will generate .vue-global-types/vue_3.4_false.d.ts in /apps/my-app/node_modules.

Then we import my-lib/src/some-comp.vue which locates in /lib/my-lib, it cannot find a vue_3.4_false.d.ts for some-comp.vue since they are in different folders.

/apps
  /node_modules
    /.vue-global-types
  main.ts
/my-lib
  /node_modules
    [missing .vue-global-types]
  /src
    some-comp.vue

@depressedX
Copy link

let dir = rootDir;
while (!host.fileExists(path.join(dir, 'node_modules', vueOptions.lib, 'package.json'))) {
const parentDir = path.dirname(dir);
if (dir === parentDir) {
throw 0;
}
dir = parentDir;
}
const globalTypesPath = path.join(dir, 'node_modules', '.vue-global-types', `${vueOptions.lib}_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`);
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + generateGlobalTypes(vueOptions.lib, vueOptions.target, vueOptions.strictTemplates);
host.writeFile(globalTypesPath, globalTypesContents);
return true;

viewed source code, seems like it'll put .vue-global-types/vue_3.4_false.d.ts on the same level of vue in node_modules.
But it's not guaranteed this file will be resolved by all triple slash of files from anywhere:

yield `/// <reference types=".vue-global-types/${options.vueCompilerOptions.lib}_${options.vueCompilerOptions.target}_${options.vueCompilerOptions.strictTemplates}.d.ts" />${newLine}`;

Anyone got any idea to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🔨 p3-minor-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants