title: create a generic function returning a function with the same signature
body: <p>In Typescript I want to create a function that will take a function and return a function with the same input-output. the function itself needs to be generic. so that it can take any number of arguments and return any type.</p>
  
  <pre><code>function improveFunction &lt;T,U&gt;(func:'that takes T and returns U') : (T):U {
    var newFunc = doDomethingToTheFunction(func); 
    return newFunc;
  }
  </code></pre>
  
  <p>if I was returning the function itself this would work. But since I am using the  arguments special parameter to be able to accept any number of argument I am in fact creating a new function that the typescript compiler can't understand.</p>
  
  <p>Edit:</p>
  
  <p>I made one more variant to go from</p>
  
  <pre><code>(U =&gt; T) to (U =&gt; Promise&lt;T&gt;)
  
  function ddd&lt;T&gt;(func: (...x: any[]) =&gt; T) : (...x: any[]) =&gt; ng.IPromise&lt;T&gt; {
      // return a function returning a promise of T;
  }
  </code></pre>