How do you remove an event listener that uses "this" in TypeScript?
<p>In JavaScript, for an event handler that needs access to private members and functions, I can rely on the function scope of those to be accessible within my event handler function, and do something like this:</p>

<pre><code>theElement.addEventListener("click", onClick);
</code></pre>

<p>and later:</p>

<pre><code>theElement.removeEventListener("click", onClick);
</code></pre>

<p>In TypeScript, I need to use an anonymous function to have <code>this</code> be the containing object, like so:</p>

<pre><code>theElement.addEventListener("click", (event) =&gt; this.onClick(event));
</code></pre>

<p>In this case, I can't remove the anonymous function from the listening to the event. How do I have an event listener as part of a class (with access to private fields and methods), that I can remove later?</p>