Closed
Description
TypeScript Version: 2.2.1 / nightly (2.2.0-dev.201xxxxx)
Code
function flatMap<ItemType, ProjectedItemType>(projectorFn: (item: ItemType) => ProjectedItemType[]): (aggregate: ProjectedItemType[], item: ItemType) => ProjectedItemType[] {
return (aggregate: ProjectedItemType[], current: ItemType) => aggregate.concat(projectorFn(current) || []);
}
['alice', 'bob'].reduce(flatMap(name => name.split('')), []);
['alice', 'bob'].reduce(flatMap<string, string>(name => name.split('')), []); // this works fine
Expected behavior:
TypeScript compiler should infer that type of name
is string
.
Actual behavior:
Compiler error: Property 'split' does not exist on type '{}'.