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
Check inferred this
parameter against interface requirement this: void
#44513
Comments
As I recall, the implicit |
IIRC, I think I recall @RyanCavanaugh saying the reason for that is because |
Found it: #35451 (comment) |
From my memory of method instantiation, that's not true; classes are already all generic, so methods shouldn't need an additional type parameter (or instantiation) to use the classes' That should be the first thing I investigate because I could easily be wrong. |
Yes, the only difference between The next question is what breaks when methods have Edit: No, I am wrong. The number of types is the same, but the method symbol also gets instantiated when there's a usage of a |
Bug Report
π Search Terms
interface method requirement this: void
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
No error
π Expected behavior
Error because the method implementation's implicit
this: Example
is not compatible with the interface requirementthis: void
.The
@typescript-eslint/unbound-method
lint rule usesthis: void
as an annotation indicating the method is allowed to be used without bindingthis
. However, there seems to be no checking from the TS compiler as to whether an inferredthis
type in a method implementation matches an interface requirement. Thus the lint rule can help you addthis: void
to the interface if you intend for functions to be usable when not bound... but neither the linter nor compiler currently help prevent runtime errors resulting from implementations with mismatchedthis
types.The text was updated successfully, but these errors were encountered: