Closed
Description
TypeScript Version: 2.2.0-dev.20161221
Code
type SomeParams<A> = { a: A, enter: (a: A) => void }
function canYouInferThis<A>(fn: () => SomeParams<A>): { aa: A } {
return { aa: fn().a }
}
const result = canYouInferThis(() => ({ a: { bla: 33 }, enter: a => undefined }))
result.aa.bla // Doesn't compile
Expected behavior:
The A
parameter should be inferred to be { bla: number }
. It seems completely unambiguous to me.
Failing that, I would expect a warning about ambiguous inferred types.
Actual behavior:
The type of A
is silently inferred to be {}