title: Using "open interfaces" to extend HTMLElement in TypeScript
body: <p>I would like to extend the built-in class HTMLElement with additional methods. Maybe I'm going mad, but I thought the following was the official idiom:</p>
  
  <pre><code>interface HTMLElement {
     swapChildBefore(remove: HTMLElement, insert: HTMLElement, before: HTMLElement): void;
  }
  
  HTMLElement.prototype.swapChildBefore =
     function (remove: HTMLElement, insert: HTMLElement, before: HTMLElement): void {
        this.removeChild(remove)
        this.insertBefore(insert, before)
     }
  </code></pre>
  
  <p>At least, according to <a href="https://stackoverflow.com/questions/12766117/how-does-prototype-extend-on-typescript">How does prototype extend on typescript?</a>, something like this should work.</p>
  
  <p>However, this seems to hide all the existing methods on HTMLElement. Is that because I've declared an interface, which hides the class of the same name? But this idiom seems to work fine with Object and Array, which are also classes.</p>