Open
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
Relevant Package
scope-manager
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Description
While working on #1991, we discovered that there's no way currently to detect if a method signature uses this
. The reason is that this:
interface X {
foo(): this;
}
Is not transformable to this:
interface X {
foo: () => this;
}
While I don't exactly understand the assignability differences and what this
means in each case, my understanding is we want to look for method signatures that reference this
, but this
has to refer to the type bound by the method, so we still keep the autofix for:
interface X {
foo(): (this: Y) => this;
}
Therefore, the best way is to track this in the scope manager, similar to how we automatically inject arguments
for FunctionScope
. In fact, for the code above, we already track this
as a normal variable.
Additional Info
No response