title: Infer union types of type guards in TypeScript
body: <p>TypeScript seems to have problems to infer union types of type guards. As an example, consider a function to combine an array of type guards with the following signature</p>
  
  <pre><code>function combine&lt;T&gt;(guards: ((x: any) =&gt; x is T)[]): (x: any) =&gt; x is T
  </code></pre>
  
  <p>and consider the following type guards with <code>A</code> and <code>B</code> having different properties</p>
  
  <pre><code>function isA(x: any): x is A
  function isB(x: any): x is B
  </code></pre>
  
  <p>Now I would expect <code>combine([isA, isB])</code> to work and have the inferred type <code>(x: any) =&gt; x is A | B</code> but instead I get an error saying that an argument of type<code>((x: any) =&gt; x is A | (x: any) =&gt; x is B)[]</code> is not assignable to parameter of type <code>(x: any) =&gt; x is A</code>, meaning that <code>T</code> is inferred as <code>A</code> rather than <code>A | B</code>.</p>
  
  <p>When specifying <code>T</code> explicitely, i.e. <code>combine&lt;A|B&gt;([isA, isB])</code>, it works as expected. Is there a way to change the signature of <code>combine</code> such that this could be inferred?</p>