title: Typing an Array with a union type in TypeScript?
body: <p>I was just wondering if it is possible to type array with a union type, so that one array can contain both Apples and Oranges but nothing else.</p>
  
  <p>Something like</p>
  
  <pre><code>var arr : (Apple|Orange)[] = [];
  
  arr.push(apple); //ok
  arr.push(orange); //ok
  arr.push(1); //error
  arr.push("abc"); // error
  </code></pre>
  
  <p>Needless to say, the example above does not work so this may not be possible, or am I missing something?</p>