Closed
Description
TypeScript Version: 2.3.2
Code
export function array<T>(array: T[], body: (element: T, i: number) => void)
{
Array.prototype.forEach.call(array, body);
}
export function object<T>(o: T, body: <U extends keyof T>(element: T[U], i: U) => void)
{
array(Object.keys(o), function (key, i)
{
body(o[key], key);
});
}
Expected behavior:
No compile error
Actual behavior:
Compile error
severity: 'Error'
message: 'Argument of type 'string' is not assignable to parameter of type 'keyof T'.'
at: '10,22'
source: 'ts'