-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Debug Failure prevents renaming imports on file move #40386
Comments
Potentially related: #37685 I am running into this issue, or one similar to it, when trying to rename a folder. (Renaming files seems to work.) I discovered that if I disable
|
I'm getting the same error using VS Code when renaming a file in a fairly small monorepo using project references. Feel free to use that project to reproduce the issue. I suspect it may have something to do with project references because I'm able to rename/refactor without issue in a project with a single Here's the TypeScript server log when attempting to rename The file rename is successful, but references are not updated as expected. I also tested this in WebStorm which was able to perform the above refactor successfully. |
I can confirm that renaming imports still is not working in v1.52.1 |
I also started experiencing this problem (renaming imports not working) when building a monorepo project using references. |
I debugged this a while ago and in my case it was because i was using |
YES!!! This is it! Thank you @bradleyayers This change made it all work for me! And by "solution" For anyone else wondering my monorepo/typescript structure is: // tsconfig.json (monorepo root)
{
"compilerOptions": {
"composite": true // and no other compilerOptions, refer to tsconfig.base.json
},
- "include": [],
+ "files": [], // changed from "include"
"references": [
{ "path": "./packages/a" },
{ "path": "./packages/b" },
{ "path": "./packages/c" },
... // etc your packages
]
} And then for other "leaf" project tsconfig files:
And my
This has to be it. Something unintended is happening when using "include" (as ideally intended) instead of "files" (workaround). First time I've seen it required when considering all the typescript references and other monorepo tutorials etc don't catch this issue. |
Something else you might enjoy is that |
Avoid the assumption that there are always include patterns: when there are none (and therefore the renamed file didn't match anyway), just skip the test for added include. Also change the code to use `return` to make it flatter. (Also get rid of a redundant type.) Fixes microsoft#40386.
Avoid the assumption that there are always include patterns: when there are none (and therefore the renamed file didn't match anyway), just skip the test for added include. Also change the code to use `return` to make it flatter. (Also get rid of a redundant type.) Fixes microsoft#40386.
Avoid the assumption that there are always include patterns: when there are none (and therefore the renamed file didn't match anyway), just skip the test for added include. Also change the code to use `return` to make it flatter. (Also get rid of a redundant type.) Fixes #40386.
TypeScript Version: 3.9.7
Search Terms:
update imports on rename, update imports on file move
Expected behavior:
When renaming a typescript file/folder in VS code, import statements pointing at the file in question should be updated.
Actual behavior:
Although this used to work, I am now running into an issue where the imports are no longer being updated.
I ran tsserver with verbose logs, and noticed the following issue which seems related to the behavior I'm seeing (entire log file uploaded too, you can see this around line 5246 of tsserver.log):
I have also attached the other tsserver.log file (named tsserver2.log in this issue). It didn't contain any explicit errors, but did contain the following:
Perhaps it's related, perhaps not.
Playground Link: n/a
Related Issues:
#28771 (Mac specific)
#30535 (performance-related)
#26927 (Seems this issue was fixed back in 2018, I'm definitely on a newer version of TS)
#24857
Attachments:
tsserver.log
tsserver2.log
The text was updated successfully, but these errors were encountered: