Closed
Description
When passing a function as a generic type T, the compiler correctly infers the return type when passing a previously declared function, but not when the same function is passed as an inline lambda. This seems to only happens with object literals. Classes and builtin return types are inferred properly.
function wrapper<T>(fn: T): T { return fn };
var fn = function(x: number) { return { x } };
// Correct: type of fnWrapper is (x: number) => { x: number }
var fnWrapper = wrapper(fn);
// Incorrect: type of inlineWrapper is (x: number) => any
var inlineWrapper = wrapper(function(x: number) { return { x } });