-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
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 atsrc. - In both directories create a
tsconfig.jsonwith any content. An empty object will do. - At
lib/lib.tscreate a file with the following content:const unrelatedLocalVariable = 123; export const someExportedVariable = unrelatedLocalVariable;
- At
src/main.tscreate a file with the following content:import * as lib from '../lib/lib.js';
- Close all tabs.
- Open
lib/lib.tsand then opensrc/main.ts. - Rename
libinsrc/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.