title: jest typescript property mock does not exist on type
body: <p>When using <code>jest.fn()</code> to add a mock you can usually access the <code>.mock</code> property to access details such as calls, something similar to this:</p>
  
  <pre><code>test('not working', () =&gt; {
      const foo = new Foo();
      foo.addListener = jest.fn();
      foo.func(); // will call addListener with a callback
      const callback = foo.addListener.mock.calls[0][0];
      expect(callback()).toEqual(1); // test the callback
  });
  </code></pre>
  
  <p>When implementing the test in typescript instead of plain javascript I get the error:</p>
  
  <blockquote>
    <p>error TS2339: Property 'mock' does not exist on type '(callback: () => number) => void'.</p>
  </blockquote>
  
  <p>I can get rid of the error by casting to <code>any</code> but surely there must be a better way:</p>
  
  <pre><code>const callback = (foo.addListener as any).mock.calls[0][0];
  </code></pre>
  
  <p>In this simple code the mock could be rewritten to store the argument using <code>jest.fn(fn =&gt; { callback = fn; });</code> but the same error happens when using <code>foo.addListener.mockClear()</code> which cannot be reworked the same way.</p>
  
  <p>So how can I get rid of the error, preferably without losing type-safety?</p>