title: Is it possible to wrap a function and retain its types?
body: <p>I'm trying to create a generic wrapper function which will wrap any function passed to it.</p>
  
  <p>At the very basic the wrapper function would look something like</p>
  
  <pre><code>function wrap&lt;T extends Function&gt;(fn: T) {
      return (...args) =&gt; {
          return fn(...args)
      };
  }
  </code></pre>
  
  <p>I'm trying to use it like:</p>
  
  <pre><code>function foo(a: string, b: number): [string, number] {
      return [a, b];
  }
  
  const wrappedFoo = wrap(foo);
  </code></pre>
  
  <p>Right now <code>wrappedFoo</code> is getting a type of <code>(...args: any[]) =&gt; any</code></p>
  
  <p>Is it possible to get <code>wrappedFoo</code> to mimic the types of the function its wrapping?</p>