-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Rename refactoring that renames constructor parameter doesn't apply to its use in the constructor #7479
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
It would be insane to propagate renames like this. We have no idea which types are actually semantically related to |
@RyanCavanaugh you could consider finding all types that are ever assigned into the type that's being renamed, right? interface I { a: number }
let x = {a: 1}; // anonymous type X that structurally matches I
let ii: I = x; // X flows into I Here, TS could infer that it should rename |
not sure that this is correct either. i would expect in some cases that you want to see these as errors after your rename session. A more appropriate solution is to do a structural comparison, and if it matches, give the user the option to change it. this is tracked by #6388 |
There's really no winning here. Consider code like this: interface HasName1 {
name: string;
}
interface HasName2 {
name: string;
}
function doSomething(x: { name: string }) {
console.log(x.name);
}
function fn() { }
var a: HasName1 = { name: 'hello' };
var b: HasName2 = { name: 'world' };
doSomething(fn);
doSomething(a);
doSomething(b); In any given rename position for |
As i noted earlier. I think there is a middle ground here. rename stays the way it is today, just because it simply makes sense in a typed language. we could add a new "structural rename", i would assume users would preview the changes here one by one, as they are mostly "suggestions", a little bit more informed than find and replace. |
From @kberg on March 11, 2016 3:2
Starting with
In this case, Student can pass for a Person. But if I rename Person.firstname to fname, there's another compiler error.
Because "Type 'Student' is not assignable to type 'Person'. Property 'fname' is missing in type 'Student'."
If, instead we concretely indicate that Student is a person,
Such a rename would propagate:
Well, mostly. The constructor broke.
Copied from original issue: microsoft/vscode#3987
The text was updated successfully, but these errors were encountered: