Bug Report
Renaming namespace (star) imports to a file in a different project than the current file will cause the first unexported symbol (variable, function, import, …) to be renamed to the same name as the import itself, if that project was either opened in the editor or referenced by the current tsconfig.json.
🔎 Search Terms
Rename refactor, Namespace import, project, composite, tsconfig, folders, directories
🕗 Version & Regression Information
This was not fixed in the most recent nightly version 4.5.0-dev.20210831.
- This changed between versions 3.7.7 and 3.8.2
- This changed between nightly versions 3.8.0-dev.20200131 and 3.8.0-dev.20200201
⏯ 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
- 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:
const unrelatedLocalVariable = 123;
export const someExportedVariable = unrelatedLocalVariable;
- At
src/main.ts create a file with the following content:
import * as lib from '../lib/lib.js';
- Close all tabs.
- Open
lib/lib.ts and then open src/main.ts.
- Rename
lib in src/main.ts.
🙁 Actual behavior
If lib/lib.ts has an unexported symbol at the very top of the file (unrelatedLocalVariable), it will rename it to the same name as the import in src/main.ts.
🙂 Expected behavior
Renaming a namespace import should not modify any external files.
Bug Report
Renaming namespace (star) imports to a file in a different project than the current file will cause the first unexported symbol (variable, function, import, …) to be renamed to the same name as the import itself, if that project was either opened in the editor or referenced by the current
tsconfig.json.🔎 Search Terms
Rename refactor, Namespace import, project, composite, tsconfig, folders, directories
🕗 Version & Regression Information
This was not fixed in the most recent nightly version
4.5.0-dev.20210831.⏯ 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
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.libinsrc/main.ts.🙁 Actual behavior
If
lib/lib.tshas an unexported symbol at the very top of the file (unrelatedLocalVariable), it will rename it to the same name as the import insrc/main.ts.🙂 Expected behavior
Renaming a namespace import should not modify any external files.