-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Tsconfig show typescript file not found error after moving it to another directory or delete it. #43838
Comments
Please share your tsconfig and a overview of your project structure |
It's an electron project, structure:
My tsconfig.json file is generated by |
I am not able to repro this with simple delete or file move.. Can you create a small repro project and list the steps (where are you moving file or which file are you deleting) Also sharing
|
You can repro this bug by these steps:
|
Following. |
I always have this error when moving unused
I have to kill and re-run |
The same hapening to me here. |
I'm also having the same problem.
My first guess was that it may have something to do with the changes not being committed, but git commit didn't help. I can try to reproduce the error and give more detailed steps if it helps. Although it may heavily depend on context and difficult to reproduce. |
What solved for me:
"scripts": {
"dev": "ts-node-dev -r tsconfig-paths/register src/main.ts"
}
"baseUrl": ".",
"paths": {
"controllers/*": [ "./src/controllers/*" ],
"helpers/*": [ "./src/helpers/*" ],
"utils/*": [ "./src/utils/*" ],
"components/*": [ "./src/components/*" ],
"interfaces/*": [ "./src/interfaces/*" ],
"middlewares/*": [ "./src/middlewares/*" ],
"models/*": [ "./src/models/*" ],
"routes/*": [ "./src/routes/*" ],
"services/*": [ "./src/services/*" ],
"validations/*": [ "./src/validations/*" ]
} Finally, just run the following: npm run dev |
Actually reopening vscode will fix this, but it's really really annoying tho, that's why I opened this issue. |
aaaaa oh no, my mistake. I should I have read a bit closer. Went a little blind with annoyance from thinking I had to reinstall the project again 😄 Thanks for the heads up, though, that's really helpful to know |
I was able to avoid this issue by restarting the typescript server (in vscode: |
Thanks! This method works for me, however I hope this issue could be fixed asap (this issue has been opened for 5 months) since it's really annoying, especially for the early dev. I've been spending around 2 hours and finally found this issue though. Thanks! |
Renaming a file causes the same problem too, I need to restart it, which takes nearly a minute, so pretty annoying Edit: @ArtyomSevyan Solved the problem for me: Changing |
I have a small solution (just to not need
But still, if you are working on vscode, the tsconfig.json file will show error, which is just distracting |
thanks its working for me :) |
@alanvitalp 's solution:
Doesn't work for me. I'm on TypeScript 5.1.3 . @PiyushDuggal-source 's solution:
Doesn't work for me either. |
{
"extends": "../../tsconfig.json",
"include" : ["./src/**/*"],
"compilerOptions": {
"rootDir": "./src"
}
} works for me. |
Thanks, I've been troubled by this question for a long time, it's useful |
Should be put on Backlog milestone. Assigning the OP was a good joke but now lets be honest, this is not making it into 5.3.0. I'm glad to be proven wrong, but so far DX seems to be one of the lowest priorities. |
this solved for me |
It's very crazy, I have a lot to finish and I can continue like this. |
I'm experiencing this error only in WSL2. It may not be related, but VSCode also seems unable to automatically fix imports of files that were renamed or moved if you are using TS path aliases. If you are not using path aliases the Main SO: Windows 10 Test cases:
|
I solved it by adding
|
I fixed it by deleting the component's file that I was importing using |
The Creating a new file, renaming a file or deleting a file will crash the TypeScript
This is causing other issues, such as new files not being detected inside of a project. Would really appreciate a fix for this as I'm having to constantly restart my TypeScript server and all related tasks for new files, file renames and deleted files. |
Hey all, I found a temporary workaround that solves this problem without needing to change your includes or restart the TypeScript server. In your {
"watchOptions": {
"watchFile": "fixedpollinginterval" // or "dynamicPriorityPolling"
}
} This issue is happening because of the way TypeScript handles file system events ( Edit: this temporary workaround only works when you're creating new files; it doesn't work if the file is renamed or is no longer available. |
I solved the problem with this modification (in linux environment):
to |
Heads up that modifying your |
I was looking for the solution then I was told just close your VScode and reopen it, the error is gone now. All my expectations that it would be a bug have gone in vain, It sucks. |
I had a similar issue
This happened when I cancelled the popup by VSC which asked
Probably in your case, copy the contents and delete the config file. Re-create it with the same contents. Hope this helps. |
Enabling My solution: Set |
Update to Typescript 5.5, it fixes this problem. The current version of VSCode ships with Typescript 5.4.5, however you can easily change it to use the "workspace" version, assuming you have installed latest Typescript in your project. Open the command palette ( #58120 (I think). |
We can just update it in VSCode, as @virtuallyunknown mentioned. This should fix the problem.
|
If you are still facing issues after updating to typescript@latest or typescript@next , please open new issue as this one is old and things have changed since then,. We need clear repro steps and tsserver log when you open the issue to be able to investigate it. |
This happened on 5.5.4. . Deleted a ts file in /src/routes/my.ts. Found this thread. Restarted TS server and now the message is gone. Will try to create a new issue if it happens again and add steps to reproduce. Steps might have been:
|
Not sure if this will help but another developer working on the same project created a folder |
For those looking for a workaround that actually does work (assuming restart TS server is an acceptable solution). When using vscode, you can install the extension https://marketplace.visualstudio.com/items?itemName=gabrielgrinberg.auto-run-command Add this to .vscode/settings.json "auto-run-command.rules": [
{
"event": "onFileRename",
"command": "typescript.restartTsServer"
},
{
"event": "onFileDelete",
"command": "typescript.restartTsServer"
},
], Relaunch window and you're done. |
Issue Type: Bug
When I move a typescript file from a directory into another directory or delete the file from vscode, it shows a problem in
tsconfig.json
file:I mean, yeah of course it's not found because I moved it into another directory.
Reopening vscode will solve this, but it is annoying ... Hope this will be fixed soon :)
VS Code version: Code 1.55.2 (3c4e3df9e89829dce27b7b5c24508306b151f30d, 2021-04-13T09:37:02.931Z)
OS version: Linux x64 5.11.0-16-generic snap
System Info
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: disabled_off
protected_video_decode: disabled_off
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
Extensions (8)
(1 theme extensions excluded)
A/B Experiments
The text was updated successfully, but these errors were encountered: