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

Renaming .vue files breaks resolving import paths #1125

Closed
Bodokh opened this issue Mar 29, 2022 · 7 comments
Closed

Renaming .vue files breaks resolving import paths #1125

Bodokh opened this issue Mar 29, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@Bodokh
Copy link

Bodokh commented Mar 29, 2022

Steps to reproduce issue:

Create new file called "Test.vue":
Before

Rename to "test.vue":
After

The error:
Cannot find module '@/models/user.model' or its corresponding type declarations.ts(2307)

I also reproduced this by creating a file called "default.vue" that worked no problem with the imports, and after renaming it to "Default.vue" it stopped working. It's as if it is impossible to rename files.

I tried restarting the volar server, deleteing the ".vscode" directory and nothing helped.
In the tsconfig.json and in vite.conte.ts I have correctly configured the mapping for the paths.
I am able to build and run the app with no issues despite the errors shown in the vscode which leads me to believe the issue is with Volar.

tsconfig:
{ "compilerOptions": { "target": "es6", "module": "esnext", "strict": true, "importHelpers": true, "moduleResolution": "node", "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "allowJs": true, "noImplicitAny": false, "strictNullChecks": false, "sourceMap": true, "baseUrl": ".", "paths": { "@/*": ["./src/*"], "~shared/*": ["../backend/src/core/models/*"] }, "types": ["vite/client", "vuetify"], "lib": ["esnext", "dom", "dom.iterable", "scripthost"], "suppressImplicitAnyIndexErrors": true, "rootDirs": ["./src"] }, "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"], "exclude": ["node_modules"] }
vite.config.ts (showing only the relevant part:
I tried this:
alias: { '@': fileURLToPath(new URL("./src", import.meta.url)) }
and also this:
alias: { '@': resolve(__dirname, 'src') }

Both work but not when changing file names.

I also tried deleting the file and creating it again and still it somehow remembers the old name and won't autocomplete the paths unless the filename is as it was initially.

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Apr 10, 2022
@Kutius
Copy link

Kutius commented May 20, 2022

maybe problem still exist

@pleek91
Copy link

pleek91 commented Jun 17, 2022

Also experiencing this +1

@yuntian001
Copy link

Also experiencing this +1 @johnsoncodehk

@yuntian001
Copy link

这个问题有修复计划么,或者对应的缓存文件夹在哪个位置,让我们临时手动清一下对应的缓存也行。
我尝试清除vs code 的缓存和重置插件都无法解决这个问题。@johnsoncodehk

@freshsnow
Copy link

Just experienced the same issue.

@AdnanRruka
Copy link

Any fi on this one?

@Harm-Nullix
Copy link

I have this issue in Webstorm 2023.2 with 1.8.2 & 1.8.8

What works for me is restarting the vue language server. (everytime a file gets added/renamed)

Its not really a fix, but a workaround if you really have to

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

No branches or pull requests

8 participants