title: typescript generic type and undefined
body: <p>I'm looking at facebook's immutable library and their typescript bindings.</p>
  
  <p>If I have this code:</p>
  
  <pre><code>const list: User[] = ...;
  list.map(user =&gt; ...)
  </code></pre>
  
  <p>The type of the lambda parameter <code>user</code> is correctly <code>User</code>.</p>
  
  <p>However, if I import immutable's <code>List</code> and wrap my array:</p>
  
  <pre><code>import {Map, List} from "immutable";
  List(list).map(user =&gt; ...)
  </code></pre>
  
  <p>Now, and it's baffling to me, the lambda parameter <code>user</code> is inferred to be <code>User | undefined</code>. Even changing the call to <code>List&lt;User&gt;(list)</code> does not help.</p>
  
  <p>Looking at the .d.ts for the library, the definition is:</p>
  
  <pre><code>export function List&lt;T&gt;(array: Array&lt;T&gt;): List&lt;T&gt;;
  </code></pre>
  
  <p>So I don't understand what is going on here?</p>