title: How do I use XMLHttpRequest in Typescript?
body: <p>This is a new situation for me, I have been using TypeScript for a long time but struggling with <code>XMLHttpRequest</code>. </p>
  
  <pre><code>request.open('GET', path);
  request.onload = () =&gt; {
     // this is fine
  }
  request.onerror = (e: ErrorEvent) =&gt; {
     // i can't figure this out
     this.registerError(e);
  }
  </code></pre>
  
  <p>How do I correctly deal with that error response?  My code above fails during compilation with this:</p>
  
  <p>error TS2322: Type <code>(e: ErrorEvent) =&gt; void</code> is not assignable to type <code>(this: XMLHttpRequest, ev: ProgressEvent) =&gt; any</code></p>
  
  <p>I wasn't expecting that. </p>
  
  <p>If you change the code to </p>
  
  <pre><code>request.onerror = (this: XMLHttpRequest, ev: ProgressEvent) =&gt; {
  };
  </code></pre>
  
  <p>It isn't valid typescript. Even if it was, <code>this</code> as a parameter name is incredibly confusing. </p>
  
  <p><strong>Would it be possible to provide an example of how to catch an XMLHttpRequest error?</strong></p>