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