unplugin / unplugin-vue-components

📲 On-demand components auto importing for Vue
https://www.npmjs.com/package/unplugin-vue-components
MIT License
3.68k stars 342 forks source link

[Bug]Can't not get right type for vue component prop #635

Closed ishowman closed 1 year ago

ishowman commented 1 year ago

Describe the bug

When I do not install unplugin-vue-components:

After install unplugin-vue-components, and add comment for import statement:

I am not sure the bug is caused by unplugin-vue-components or vue-tsc, please check it.

how i create the repo

Reproduction

https://github.com/ishowman/vue3-ts-buiild-bug/tree/vue-components

System Info

Plugins: (already finish setup with volar-takeover-mode)

pnpm: 8.5.1
node: 18.12.1

 System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    Memory: 1.97 GB / 7.86 GB
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (113.0.1774.50)
    Internet Explorer: 11.0.19041.1566

Used Package Manager

pnpm

Validations

ishowman commented 1 year ago

@antfu I am not sure the bug is caused by unplugin-vue-components or vue-tsc, could you do me a favour? pnpm vue-tsc -v return the same typescript version as volar and package.json, so I can sure they are use the same typescript version.

lishaobos commented 1 year ago

hi, just put your components.d.ts in src directory

Components({
      dts: './src/components.d.ts'
    })

image

ishowman commented 1 year ago

hi, just put your components.d.ts in src directory

Components({
      dts: './src/components.d.ts'
    })

image

I've move the file and change the file path in tsconfig.app.json, and choose Volar: restart vue serverimage

image

Still not work, and pnpm build still passed with no error: image image

lishaobos commented 1 year ago

what is your pkg manager name, npm or pnpm?

ishowman commented 1 year ago

your pkg manager is npm or pnpm

pnpm

lishaobos commented 1 year ago

your pkg manager is npm or pnpm

pnpm

exec pnpm add @vue/runtime-core -D

and restart your ide

ishowman commented 1 year ago

your pkg manager is npm or pnpm

pnpm

exec pnpm add @vue/runtime-core -D

and restart your ide

So amazing, why it works but docs didn't tell me to install it? @lishaobos

lishaobos commented 1 year ago

i think is pnpm bug or limit

ishowman commented 1 year ago

i think is pnpm bug or limit

If install dependencies with npm or yarn, it will work normally without pnpm add @vue/runtime-core -D?

lishaobos commented 1 year ago

If install dependencies with npm or yarn, it will work normally without pnpm add @vue/runtime-core -D?

looks like it.

ishowman commented 1 year ago

your pkg manager is npm or pnpm

pnpm

exec pnpm add @vue/runtime-core -D

and restart your ide

If I build project in ci ,and ci do not have any ide to reload,what should I do?

lishaobos commented 1 year ago

your pkg manager is npm or pnpm

pnpm

exec pnpm add @vue/runtime-core -D and restart your ide

If I build project in ci ,and ci do not have any ide to reload,what should I do?

ci do not need to reload.

ishowman commented 1 year ago

your pkg manager is npm or pnpm

pnpm

exec pnpm add @vue/runtime-core -D and restart your ide

If I build project in ci ,and ci do not have any ide to reload,what should I do?

ci do not need

your pkg manager is npm or pnpm

pnpm

exec pnpm add @vue/runtime-core -D and restart your ide

If I build project in ci ,and ci do not have any ide to reload,what should I do?

ci do not need to reload.

ci can't find type error in this case, and will pass when run npm scripts build.

daiwanxing commented 1 year ago

I found the same issue #355. It's looks like a pnpm bug or feature, and some people provided two ways to solve it

finally restart your vscode, It' will be solved.

ishowman commented 1 year ago

will it not work in ci for there is no vscode in ci? I am confuse about why restar vscode is necessary, while ci need to run buildscript to check types.

lishaobos commented 1 year ago

will it not work in ci for there is no vscode in ci? I am confuse about why restar vscode is necessary, while ci need to run buildscript to check types.它会在 CI 中不起作用,因为 CI 中没有 VScode?我对为什么需要重新命名 vscode 感到困惑,而 ci 需要运行 build 脚本来检查类型。

because need trigger syntax highlighting on vscode, nothing else.

ishowman commented 1 year ago

will it not work in ci for there is no vscode in ci? I am confuse about why restar vscode is necessary, while ci need to run buildscript to check types.它会在 CI 中不起作用,因为 CI 中没有 VScode?我对为什么需要重新命名 vscode 感到困惑,而 ci 需要运行 build 脚本来检查类型。

because need trigger syntax highlighting on vscode, nothing else.

so the type-checking of vue-tsc will work normally if no vscode reload, right?

lishaobos commented 1 year ago

will it not work in ci for there is no vscode in ci? I am confuse about why restar vscode is necessary, while ci need to run buildscript to check types.它会在 CI 中不起作用,因为 CI 中没有 VScode?我对为什么需要重新命名 vscode 感到困惑,而 ci 需要运行 build 脚本来检查类型。

because need trigger syntax highlighting on vscode, nothing else.

so the type-checking of vue-tsc will work normally if no vscode reload, right?

yes, 😎

richex-cn commented 1 year ago

I got similar problem and resolved it with https://github.com/antfu/unplugin-vue-components/issues/635#issuecomment-1560678975

wenfangdu commented 1 year ago

Will be fixed by https://github.com/antfu/unplugin-vue-components/pull/638.