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
Typescript cannot find module using @ absolute path syntax Visual Studio Code Volar error #35
Comments
Volar alone is not enough for the latest templates. |
I tried TypeScript Vue Plugin along with Volar and I still get the error. I'll look into that issue you referenced and try Take Over Mode. Do root paths using |
I followed the instructions in the README of my scaffolded project to enable Take Over Mode. After restarting the window, I saw the alert saying Take Over Mode is enabled. I still get the error on Thanks for any assistance. |
Have you disabled Vetur? Do you have a screenshot of the error? |
Seems like the typescript in VS Code doesn't like file extensions ending with I followed the advice in this stackoverflow thread and it's now working for me. I've created a demo repo that can hopefully reproduce the error. Also getting a bunch of eslint prettier errors off the bat which doesn't make for very good DX but that's a separate issue. https://github.com/richardvanbergen/test-repo-vue-project Reproduction steps
Workaround / fix
Other informationVS Code typescript version: 4.5.4 |
@tetradice Interesting. I have versions 0.31.1 for both. I even disabled all other extensions and restarted Visual Studio Code. I'm on Windows, but that shouldn't matter. Curious - does it work if you disable TypeScript Vue Plugin? |
Still can't reproduce… Are you creating the project in a monorepo? |
@richardvanbergen You didn't have TypeScript Vue Plugin (Volar) installed. |
Haha yes thanks I have just figured that out. Is there any reason it's split into two? |
Before 0.27.22 it was integrated into Volar (with an option to turn it on/off). |
Hmm... When I tried it, I found something different from what I expected. Even if I disabled the TypeScript Vue Plugin, importing *.vue files in However, importing vue files in The following can be inferred from these.
I'm not sure why importing from vue files isn't working only in the pholly environment. But in any case, this is likely to be in the Volar side, not the create-vue side. So I think it would be better to send this issue to Volar's issues. My Environment
|
@tetradice that's a good find. I can confirm that with the Typescript Vue Plugin (Volar) Not sure why root path imports aren't recognized for me inside .vue files even when I have Vue Language Features (Volar). I uninstalled and reinstalled just to be sure. I'll take up an issue with Volar's repo. Thanks for your help! |
Closing as the issue has been resolved in Volar's repo. |
When creating a new app with TypeScript, any imports using absolute path syntax '@/' show as errors in Visual Studio Code with the Volar extension. The app still runs fine.
Steps to reproduce:
IDE: Visual Studio Code
Extension: Volar
Change an import to use
@/
absolute syntax, such as inApp.vue
change the HelloWorld.vue import toimport HelloWorld from '@/components/HelloWorld.vue'
There will now be a red line error:
Cannot find module '@/components/HelloWorld.vue' or its corresponding type declarations.ts(2307)
Note: if you choose to install router when configuring create-vue,
App.vue
will already use the absolute path syntax and have an error.Extra info
The text was updated successfully, but these errors were encountered: