vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.79k stars 390 forks source link

Missing props suggestion for custom component #4676

Closed thoriqadillah closed 1 month ago

thoriqadillah commented 1 month ago

Vue - Official extension or vue-tsc version

2.0.28

VSCode version

1.91.1

Vue version

^3.4.29

TypeScript version

~5.4.0

System Info

System:
    OS: Linux 6.9 Fedora Linux 39 (KDE Plasma)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 21.22 GB / 31.14 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.12.2/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 9.1.0 - ~/.nvm/versions/node/v20.12.2/bin/pnpm
    bun: 1.1.8 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 126.1.67.123

Steps to reproduce

I use shadcn-vue for my component because im to lazy to create one.

  1. install shadcn vue
  2. add button component
  3. import the button component
  4. see the result

What is expected?

there should be props suggestion like what is the available props for this component

What is actually happening?

there is no props suggestion. preview: image

Link to minimal reproduction

No response

Any additional comments?

No response

KazariEX commented 1 month ago

Can't reproduce. Please provide a minimal reproduction.

image

RayGuo-ergou commented 1 month ago

Most likely you did not include the file in tsconfig

thoriqadillah commented 1 month ago

can you take a look at my project here? i tried to reproduce this issue with new project and it works perfectly fine. but not for that particular project @RayGuo-ergou @KazariEX @KermanX

KazariEX commented 1 month ago

Just bump all your deps to the latest version to ensure GlobalComponents can be exported correctly from vue.

thoriqadillah commented 1 month ago

my current deps version is already similar (latest) with the project i newly created. and what do you mean by this

to ensure GlobalComponents can be exported correctly from vue

KazariEX commented 1 month ago

Due to some issues between declare module '@vue/runtime-core' and declare module 'vue' in the old deps, the GlobalComponents cannot be exported from vue correctly, resulting in the component type being inferred as any.

image

image

RayGuo-ergou commented 1 month ago

as @KazariEX mentioned, you just have to bump all your deps to the newest version (similar !== newest)

You probably did not declare vue global components but your libraries may do. image

diff --git a/web/package.json b/web/package.json
index 55bd736..a7e890e 100644
--- a/web/package.json
+++ b/web/package.json
@@ -12,31 +12,32 @@
   },
   "dependencies": {
     "@radix-icons/vue": "^1.0.0",
-    "@vueuse/core": "^10.11.0",
-    "axios": "^1.7.3",
+    "@vueuse/core": "^11.0.0",
+    "axios": "^1.7.4",
     "class-variance-authority": "^0.7.0",
     "clsx": "^2.1.1",
     "non.geist": "^1.0.3",
-    "pinia": "^2.1.7",
-    "radix-vue": "^1.9.2",
-    "tailwind-merge": "^2.4.0",
+    "pinia": "^2.2.2",
+    "radix-vue": "^1.9.4",
+    "tailwind-merge": "^2.5.2",
     "tailwindcss-animate": "^1.0.7",
-    "vue": "^3.4.29",
-    "vue-router": "^4.3.3"
+    "vue": "^3.4.38",
+    "vue-router": "^4.4.3"
   },
   "devDependencies": {
     "@iconify/vue": "^4.1.2",
     "@tsconfig/node20": "^20.1.4",
-    "@types/node": "^20.14.5",
-    "@vitejs/plugin-vue": "^5.0.5",
+    "@types/node": "^20.15.0",
+    "@vitejs/plugin-vue": "^5.1.2",
     "@vue/tsconfig": "^0.5.1",
-    "autoprefixer": "^10.4.19",
-    "npm-run-all2": "^6.2.0",
-    "postcss": "^8.4.40",
-    "tailwindcss": "^3.4.7",
-    "typescript": "~5.4.0",
-    "vite": "^5.3.1",
-    "vite-plugin-vue-devtools": "^7.3.1",
-    "vue-tsc": "^2.0.21"
-  }
+    "autoprefixer": "^10.4.20",
+    "npm-run-all2": "^6.2.2",
+    "postcss": "^8.4.41",
+    "tailwindcss": "^3.4.10",
+    "typescript": "~5.5.4",
+    "vite": "^5.4.1",
+    "vite-plugin-vue-devtools": "^7.3.8",
+    "vue-tsc": "^2.0.29"
+  },
+  "packageManager": "pnpm@9.7.1"
 }

Just a kind suggestion, if someone gave you a suggestion and if it's not that hard to do. Please try first rather than just "guess" :).

thoriqadillah commented 1 month ago

bump the version indeed fix the issue. thanks. sorry, i thought that bumping the version == make the version similar to the newly created project. i wasn't aware of that. thanks for the help