title: Mapping from one union type to another in typescript
body: <p>I've been enjoying union types in typescript, but I've just hit my first snag. </p>
  
  <p>This is the member in question:</p>
  
  <pre><code>organizations: Organization[] | number[];
  </code></pre>
  
  <p>This is what I'm trying to do:</p>
  
  <pre><code>let orgs = organziations.map(org =&gt; org.id);
  </code></pre>
  
  <p>In other words, take this collection of <code>&lt;Organization[]&gt;</code> and map it to its id so that I can have instead a collection of <code>&lt;number[]&gt;</code>.</p>
  
  <p>The error I get is <strong>[ts] Cannot invoke an expression whose type lacks a call signature</strong>. True, map doesn't know which of the types it is dealing with. Unfortunately, nothing I've tried thus far has helped map out.</p>