4

I took some class member variables and moved them into a separate class in another file. Those variables were heavily-used in the project, so about 1000 .ts files need their imports changed to reference the new class/file.

WebStorm has a useful move option, but only updates references if you move an entire class, function, or variable.

WebStorm also provides auto-import, but only works 1 single file at a time.

Is there an IDE / plugin / tool that would scan my entire project and update all these references?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
luker02
  • 387
  • 2
  • 5
  • 13
  • see also [Visual Studio Code Automatic Imports](https://stackoverflow.com/questions/38210604) and [Can VS Code automatically update JavaScript and TypeScript import paths on file rename/move?](https://stackoverflow.com/questions/43542247) ... and more generally [ts-morph](https://github.com/dsherret/ts-morph/) and [jscodeshift](https://github.com/facebook/jscodeshift) – milahu Oct 11 '22 at 14:26

1 Answers1

0

Before extracting them to a separate class you can use rename feature renaming to new class and a property name (name with dot is invalid, but refactor will perform replacement anyway). That would temporary make the code broken, but you'll be able to use Find and Replace. If your new class name doesn't seem to be unique enough, rename to temporary more unique name.

Qwertiy
  • 19,681
  • 15
  • 61
  • 128