vuejs / language-tools

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

Intellisense not working for auto-import components #1314

Closed ChrisGV04 closed 2 years ago

ChrisGV04 commented 2 years ago

Hi! I'm currently developing a website and I used the Vitesse template as a starting point but I modified it to fit my needs a bit more. At first, everything was working fine, but now I'm not getting Intellisense on my global components that are imported with the unplugin-vue-components inside of my templates for some reason.

I have used this exact template before and the Intellisense works fine, but on this project it just doesn't show intellisense for my auto imported components.

You can view my code at this repo.

As you can see, it is mostly a copy of Vitesse, but I removed some dependencies and added some extra ones like Tailwind and HeadlessUI. I created a basic BaseButton component with some props to test the Intellisense but it says that the component is of type any even if the components.d.ts file has it:

screenshot

I also noticed that in another similar project using the same setup at the bottom of my VS Code editor I get Tag: PascalCase and intellisense works fine, but on the project I shared previously I get Tag: UNSURE. I don't know if that is relevant.

Screen Shot 2022-05-18 at 3 45 19 p m

I already tried:

I have both the Volar v0.34.15 and Typescript Vue Plugin v0.34.15 extension installed

ChrisGV04 commented 2 years ago

I finally found the solution to this problem! It turns out it was happening because of my package manager being pnpm and something related to the way it manages the dependencies.

I solved it by creating a .npmrc file at the root of my project with the following:

shamefully-hoist=true
strict-peer-dependencies=false

Then I deleted the node_modules folder and ran pnpm i again. That did the trick!

Found the solution from this issue in case someone finds themselves on the same issue I had.