-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
TypeScript Version: 3.4.0-dev.20190207, 3.3.0
Search Terms:
type parameter, callback
Code
interface Bar<T> {
<B_RETURN>(
a: (aParam: B_RETURN) => any,
b: (bParam: T) => B_RETURN // B_RETURN is supposed to be inferred from here
): any
}
declare const bar: Bar<any>
bar((aParam) => 1, () => 'abc') // OK! `aParam` is `string`
bar((aParam) => 1, (bParam) => 'abc') // `aParam` is `{}`. Why?
bar((aParam) => 1, (bParam: any) => 'abc') // `aParam` is `string`. Again, why?
let arg2 = (bParam) => 'abc' ; bar((aParam ) => 1, arg2) // `aParam` is `string`. Again, why?Expected behavior:
aParam should be string in each of the four examples
Actual behavior:
aParam is for some reason {} instead of string in the second example
Playground Link: link
I would be very grateful if someone can give me some quick directions (Is it a bug? What am I missing?). My work depends on it in a great degree.
P.S. Asked on stackoverflow and got no answer.
przemyslawjanpietrzak
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed