title: Mock dependency in Jest with TypeScript
body: <p>When testing a module that has a dependency in a different file and assigning that module to be a <code>jest.mock</code>, TypeScript gives an error that the method <code>mockReturnThisOnce</code> (or any other <code>jest.mock</code> method) does not exist on the dependency, this is because it is previously typed.</p>
  <p>What is the proper way to get TypeScript to inherit the types from <code>jest.mock</code>?</p>
  <p>Here is a quick example.</p>
  <p>Dependency</p>
  <pre><code>const myDep = (name: string) =&gt; name;
  export default myDep;
  </code></pre>
  <p>test.ts</p>
  <pre><code>import * as dep from '../depenendency';
  jest.mock('../dependency');
  
  it('should do what I need', () =&gt; {
    //this throws ts error
    // Property mockReturnValueOnce does not exist on type (name: string)....
    dep.default.mockReturnValueOnce('return')
  }
  </code></pre>
  <p>I feel like this is a very common use case and not sure how to properly type this.</p>