-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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 compileExpected 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 {}
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript