title: TypeScript - typeof array of union types
body: <p>If I have array of union I can check for typeof value this way:</p>
  
  <pre><code>//case 1
  function something1(a1: Array&lt;number | string | boolean&gt;)
  {
      for (const v of a1)
          if (typeof v === "number")
              v;  //v is number
          else if (typeof v === "boolean")
              v;  //v is boolean
          else
              v;  //v is string
  }
  </code></pre>
  
  <p>If I have union of array I could do it the same way:</p>
  
  <pre><code>//case 2
  function something2(a1: Array&lt;number&gt; | Array&lt;string&gt; | Array&lt;boolean&gt;)
  {
      for (const v of a1)
          if (typeof v === "number")
              v;  //v is number
          else if (typeof v === "boolean")
              v;  //v is boolean
          else
              v;  //v is string
  }
  </code></pre>
  
  <p>but I want to avoid checking for type inside loop:</p>
  
  <pre><code>//case 3
  function something3(a1: Array&lt;number&gt; | Array&lt;string&gt; | Array&lt;boolean&gt;)
  {
      if (a1.length === 0)
          return;
      if (typeof a1[0] === "number")
          a1;  //should be number[]!!     but it is  number[] | string[] | boolean[]
      if (typeof a1[0] === "boolean")
          a1;  //should be boolean[]!!    but it is  number[] | string[] | boolean[]
      if (typeof a1[0] === "string")
          a1;  //should be string[]!!     but it is  number[] | string[] | boolean[]
  }
  </code></pre>
  
  <p>but a1 is not recognised as number[] or string[] or boolean[].<br>
  But this makes sense. Since all items in array are the same type. Is it possible to achieve that? </p>
  
  <p>I am using TypeScript beta 2.0.</p>