microsoft / microsoft/TypeScript
Renaming file doesn't update imports in other projects which reference this project
Open
Nobody has claimed this yet.
Experience Enhancement
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Bug Report
🔎 Search Terms
rename file folder move project references
💻 Code
Reduced test case: https://github.com/OliverJAsh/ts-project-references-rename-bug-test-44411
tsconfig.json:
{
"files": [],
"references": [
{
"path": "./app/tsconfig.json"
},
{
"path": "./shared/tsconfig.json"
}
]
}
shared/tsconfig.json:
{
"compilerOptions": {
"composite": true
}
}
shared/foo.ts:
export const foo = 1;
shared/bar.ts:
import { foo } from "./foo";
foo
app/tsconfig.json:
{
"compilerOptions": {
"composite": true,
"paths": {
"shared/*": ["../shared/*"]
}
},
"references": [
{
"path": "../shared/tsconfig.json"
}
]
}
app/main.ts:
import { foo } from "shared/foo";
foo;
Steps to reproduce
- Open VS Code and navigate to
shared/foo.ts - Wait for VS Code to finish initialising TS.
- Rename the file to something else e.g.
foo2.ts
🙁 Actual behavior
- File is renamed
- Imports in the current project are updated
- Imports in other projects which reference this project are not updated
🙂 Expected behavior
- File is renamed
- Imports in the current project are updated
- Imports in other projects which reference this project are updated. For example,
app/main.tswhich importsshared/foo.ts.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reduced test case and reproduce the rename from shared/foo.ts to another name while observing app/main.ts and the project references in the two tsconfig.json files. Review the linked tsserver.log and compare import updates within shared with updates in the referencing app project; done means app/main.ts is updated too.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100