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

useAliasesForRenames does not prevent rename in the original file in another project #45734

Closed
esdmr opened this issue Sep 5, 2021 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Refactorings e.g. extract to constant or function, rename symbol Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Help Wanted You can do this Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@esdmr
Copy link

esdmr commented Sep 5, 2021

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.

  • This changed between versions 3.1.8 and 3.2.1
  • This changed between nightly versions 3.2.0-dev.20181114 and 3.2.0-dev.20181115

⏯ 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.useAliasesForRenames is enabled (default).

  1. Create two directories. One at lib, and the other at src.
  2. In both directories create a tsconfig.json with any content. An empty object will do.
  3. At lib/lib.ts create a file with the following content:
    export const variable = 123;
  4. At src/main.ts create a file with the following content:
    import { variable } from '../lib/lib.js';
  5. Close all tabs.
  6. Open lib/lib.ts and then open src/main.ts.
  7. Rename variable in src/main.ts.

🙁 Actual behavior

In addition to creating an alias in src/main.ts like the following variable as newName, the original file lib/lib.ts also has its exported variable variable renamed to newName. This causes Typescript to err that lib/lib.js has no exported member named variable.

🙂 Expected behavior

If typescript.preferences.useAliasesForRenames is 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.

@andrewbranch andrewbranch added the Domain: Refactorings e.g. extract to constant or function, rename symbol label Sep 7, 2021
@andrewbranch andrewbranch added this to the TypeScript 4.5.1 milestone Sep 7, 2021
@andrewbranch andrewbranch added the Bug A bug in TypeScript label Sep 7, 2021
@andrewbranch andrewbranch added Good First Issue Well scoped, documented and has the green light Help Wanted You can do this Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". and removed Good First Issue Well scoped, documented and has the green light labels Sep 7, 2021
@andrewbranch
Copy link
Member

Related: #45659

@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Dec 15, 2021
@esdmr
Copy link
Author

esdmr commented May 3, 2022

This is fixed by #48758. 🎉

@esdmr esdmr closed this as completed May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Refactorings e.g. extract to constant or function, rename symbol Effort: Casual Good issue if you're already used to contributing to the codebase. Harder than "good first issue". Help Wanted You can do this Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests

4 participants