-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Allow structural reference-finding in the language service #6388
Comments
The scope of this change is more than a bug fix. marking it as a suggestion. there is also a VS/Editor aspect here as there is a new UI/option to be provided to the user at rename time. |
Note to implementors: a basic, but useful, useful test case would be interface A {
a: string;
}
function f(): Promise<A> {
return Promise.resolve({
a: '',
});
} taken from #6244. |
I think it should stay as it is now. Correct me if I am wrong, your latter example would work aout of the box, had TypeScript crave the type out of the context which it doesn't currently do. You would've killed many birds with a single shot if it did. |
The proposal is an option to look for compatible types when performing a rename/search, so this wouldn't affect you if you didn't want it to. It depends what you mean by "crave", because what it comes down to in our current algorithms is stepping through levels of type argument inference and contextual typing. If there's a solid and general idea about figuring that out, it'd be worth considering. |
Closing due to lack of additional feedback |
Consider the following:
This code works because
{ a: string; b: number }
is structurally compatible withA
.Imagine that a user tries to rename
a
in either the interface or the object literal. Right now, renaming either one will cause an error, because the two are not considered the same property in their containing type. This leads to an unpleasant refactoring experience, because code actually stops working correctly.We should consider fixing this by testing whether the containing type is structurally compatible.
This change should definitely affect:
The text was updated successfully, but these errors were encountered: