-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Renaming interface members and object shorthand property names #12007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
the problem is the RenameLocation interface returns to the IDE/Editor a list of rename locations; here you would need to send a list of edits as well. i.e. |
Then maybe this would be easier and still better: interface Test {
foo2: string
}
function bar(): Test {
const foo2 = 'foo' // <---- rename variable as well, so that next line is not broken
return { foo2 }
} |
that might be easier. |
Renaming variable wouldn't always work, right? Because if you rename only the interface Test1 {
foo: string;
}
interface Test2 {
foo: string;
}
function bar(): [Test1, Test2] {
const foo = 'foo';
return [{ foo }, { foo }];
} this should end up looking not like this interface Test1 {
foo2: string;
}
interface Test2 {
foo: string;
}
function bar(): [Test1, Test2] {
const foo2 = 'foo';
return [{ foo2 }, { foo2 }];
} but like this: interface Test1 {
foo2: string;
}
interface Test2 {
foo: string;
}
function bar(): [Test1, Test2] {
const foo = 'foo';
return [{ foo2: foo }, { foo }];
} I thought renaming was pretty safe until I came across this issue... but on the bright side, typechecks should normally catch the errors. |
Because of this bug, renaming an interface member typically produces incorrect code, from what I've seen. It's almost enough to make me mistrust the "rename symbol" feature... but is this basically the only glaring bug, in people's experience? |
Adding @TimFerrell who also shared this feedback which shows up in Visual Studio Code |
Correct, this issue applies to Javascript as well. |
Yes and the refactoring in VS code is driven by TypeScript under the hood. I think once this issue is addressed here in TypeScript it will also address the similar issue you noticed around the refactor features in the editor. |
IMHO. this issue should be labeled as a bug. |
I stumbled a few times because of this bug. I have seen bugs in our code because of this. I would appreciate this being fixed. |
It seems the bug is back on the latest VSCode version (Typescript 5.5.4): Screen.Recording.2024-12-23.at.10.52.37.PM.mov"About VSCode" details:
|
@tmoran-stenoa likely you have the "Use aliases for renames" option set wrong |
@RyanCavanaugh You're right, it was off, works well now that it's enabled. Thank you so much!! |
TypeScript Version: nightly (2.1.0-dev.20161102)
Code
Rename
foo
on line2
tofoo2
Expected behavior:
Actual behavior:
The text was updated successfully, but these errors were encountered: