title: Function that takes generic arguments and returns generic value
body: <p>I have a function:</p>
  
  <p><code>const r = (array, function) =&gt; { some stuff }</code></p>
  
  <p>However <code>array</code> and <code>function</code> arguments can be <strong>anything</strong>, but array <strong>must be typeof array</strong> and function <strong>must be typeof function</strong>. </p>
  
  <p>However, the <code>array</code> can be array of anything - <code>any[]</code> anf <code>function</code> can be anything <code>function(...r: any): any</code>.</p>
  
  <p>How can I type that <code>r</code> function to accept generic <code>array</code> and <code>function</code> arguments, but the type definition has to be passed when calling it?</p>
  
  <p>E.g. 
  Im calling it somewhere in my app:</p>
  
  <p><code>r([1,2,3], (r) =&gt; r + 2)</code></p>
  
  <p>Thanks!</p>