Suggestion: typechecking of 'this' context #15
Labels
Duplicate
An existing issue was already created
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
Suggestion
An idea for TypeScript
A common error in TypeScript is to lose the
this
context, especially in class situations:The compiler should detect when this happens and issue an error:
We need a proposal here that determines why this would be an error, in a way that is not burdensome. For example, we do want it to be valid to call e.g.
function#bind
onm.printX
, and it should probably valid to write something likeif(m.printX) { m.printX() }
.This gets even trickier when we look at the members of
window
-- some of them can be invoked with anythis
, but others cannot. It should be possible to describe these differences.The text was updated successfully, but these errors were encountered: