title: Jasmine custom matcher type definition
body: <p>I am trying to add typescript definition to a jasmine matcher <a href="https://github.com/MassimoFoti/jasmineMatchers" rel="nofollow noreferrer">library</a>.</p>
  
  <p>I was able to add the matchers for the generic type <code>T</code> but now i want to add matchers only to DOM elements.</p>
  
  <p>Digging into the jasmine type definition code I found a similar approach to <code>ArrayLike</code> (see <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/jasmine/index.d.ts#L85" rel="nofollow noreferrer">here</a> for the <code>expect</code> overload and <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/jasmine/index.d.ts#L455-L460" rel="nofollow noreferrer">here</a> for the <code>ArrayLikeMatchers</code>).</p>
  
  <p>So I created a similar one.</p>
  
  <pre><code>// Overload the expect
  declare function expect&lt;T extends HTMLElement&gt;(actual: T): jasmine.DOMMatchers&lt;T&gt;;
  
  declare namespace jasmine {
      // Augment the standard matchers. This WORKS!
      interface Matchers&lt;T&gt; {
          toBeExtensible(): boolean;
          toBeFrozen(): boolean;
          toBeSealed(): boolean;
          // ... other
      }
      // The matchers for DOM elements. This is NOT working!
      interface DOMMatchers&lt;T&gt; extends Matchers&lt;T&gt; {
          toBeChecked(): boolean;
          toBeDisabled(): boolean;
      }
  }
  </code></pre>
  
  <p>But, is not working :(</p>
  
  <p>Given the following code:</p>
  
  <pre><code>const div = document.createElement("div");
  expect(div).toBeChecked();
  </code></pre>
  
  <p>The type checker is giving me the error:</p>
  
  <blockquote>
    <p>[js] Property 'toBeChecked' does not exist on type 'Matchers'.</p>
  </blockquote>
  
  <hr>
  
  <p>The only solution seems to be adding the <code>expect</code> overload <strong>before</strong> the generic <code>expect</code> (after the <code>ArrayLike</code> overload <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/jasmine/index.d.ts#L85" rel="nofollow noreferrer">here</a>) in the core jasmine library.</p>
  
  <p>But... it is not doable :)</p>
  
  <p>Any hint on how to properly implement a working solution?</p>