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).
- Create two directories. One at
lib, and the other at src.
- In both directories create a
tsconfig.json with any content. An empty object will do.
- At
lib/lib.ts create a file with the following content:
export const variable = 123;
- At
src/main.ts create a file with the following content:
import { variable } from '../lib/lib.js';
- Close all tabs.
- Open
lib/lib.ts and then open src/main.ts.
- 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.
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.