Thanks for your response!
Ok, I've figured this out. Using F2 outside the place it's declared will alias it. Doing it on the import statement will also alias it.
e.g. Using F2 anywhere in this file
someFile.js
import { Clock } from './clocks' const c = new Clock();
will result in
import { Clock as C } from './clocks' const c = new C();
On the other hand, if you use it where it's exported it will look for all instances of it in your code and replace it.
e.g.
clocks.js
export class Clock { // stuff }
Would become
export class C { // stuff }
import { C } from './clocks' const c = new C();
You're right, I didn't realize that, thanks! I guess the reason is indeed because that "blindly" renaming on import statements will mess up external stuff that we might consider static (eg. installed NPM modules).
Yeah! When you said:
VSCode does the renaming conservatively
It sort of made it click for me! Anyway, thanks for your article and response! Following now!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for your response!
Ok, I've figured this out. Using F2 outside the place it's declared will alias it. Doing it on the import statement will also alias it.
e.g. Using F2 anywhere in this file
someFile.js
will result in
On the other hand, if you use it where it's exported it will look for all instances of it in your code and replace it.
e.g.
clocks.js
someFile.js
Would become
clocks.js
someFile.js
You're right, I didn't realize that, thanks! I guess the reason is indeed because that "blindly" renaming on import statements will mess up external stuff that we might consider static (eg. installed NPM modules).
Yeah! When you said:
It sort of made it click for me! Anyway, thanks for your article and response! Following now!