You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classResetButton{render(){returnmakeButton({text: 'Reset',onClick: this.onClick});}onClick=()=>{alert(`Reset ${this}`);// "this" refers to the ResetButton instance.}}
classResetButton{constructor(){this.onClick=()=>{alert(`Reset ${this}`);// "this" refers to the ResetButton instance.};}render(){returnmakeButton({text: 'Reset',onClick: this.onClick});}}
functionaddKeyListener(el: HTMLElement,listener: (this: HTMLElement,e: KeyboardEvent)=>void){el.addEventListener('keydown',e=>{listener(e);// ~~~~~~~~ The 'this' context of type 'void' is not assignable// to method's 'this' of type 'HTMLElement'});}
classFoo{registerHandler(el: HTMLElement){addKeyListener(el,e=>{console.log(this.innerHTML);// ~~~~~~~~~ Property 'innerHTML' does not exist on 'Foo'});}}