title: Can you extend a function in TypeScript?
body: <p>I help maintain a JavaScript library that produces spy functions which allow you to inspect how a passed-in function was called (mainly for use in unit testing).</p>
  
  <p>The library creates a function that has additional properties on it that allow you to inspect the calls.</p>
  
  <p>Is it possible to create a TypeScript definition that will allow the function to be passed in to methods that require a function AND have extra properties?</p>
  
  <p>This is invalid, but something like:</p>
  
  <pre><code>class Spy extends function {
      wasCalled: () =&gt; boolean;
      ...
  }
  </code></pre>
  
  <p>Which would allow me to pass a spy into a function with this signature:</p>
  
  <pre><code>function subjectUnderTest(callback:() =&gt; void) {
      ...
  }
  </code></pre>