-
Notifications
You must be signed in to change notification settings - Fork 13.4k
useAliasesForRenames does not prevent rename in the original file in another project #45734
Copy link
Copy link
Closed
Closed
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbolEffort: CasualGood issue if you're already used to contributing to the codebase. Harder than "good first issue".Good issue if you're already used to contributing to the codebase. Harder than "good first issue".Help WantedYou can do thisYou can do thisRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbolEffort: CasualGood issue if you're already used to contributing to the codebase. Harder than "good first issue".Good issue if you're already used to contributing to the codebase. Harder than "good first issue".Help WantedYou can do thisYou can do thisRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Type
Fields
Give feedbackNo fields configured for issues without a type.
Bug Report
🔎 Search Terms
Rename refactor, Named import, Alias for renames, project, tsconfig, folders, directories
🕗 Version & Regression Information
This was not fixed in the most recent nightly version 4.5.0-dev.20210905.
⏯ Playground Link
Typescript workbench apparently does not support JSON files, therefore it can not create multiple projects required to reproduce this bug.
Here is the link to GitHub MWE Repo.
💻 Code
Make sure that
typescript.preferences.useAliasesForRenamesis enabled (default).lib, and the other atsrc.tsconfig.jsonwith any content. An empty object will do.lib/lib.tscreate a file with the following content:src/main.tscreate a file with the following content:lib/lib.tsand then opensrc/main.ts.variableinsrc/main.ts.🙁 Actual behavior
In addition to creating an alias in
src/main.tslike the followingvariable as newName, the original filelib/lib.tsalso has its exported variablevariablerenamed tonewName. This causes Typescript to err thatlib/lib.js has no exported member named variable.🙂 Expected behavior
If
typescript.preferences.useAliasesForRenamesis enabled, then only create the alias. Do not rename the exported variable as well. This behaviour is currently done when the two files are in the same project.