Open
Description
opened on Jan 17, 2019
TypeScript Version: 3.3.0-dev.20190117
Search Terms: generic type inference, union types
Code
function f1<A1, B1>(cb: (a: A1, b: B1) => void) {
f2(cb); // I expect no errors
}
function f2<A2, B2>(cb: ((x: number, a: A2, b: B2) => void)|
((a: A2, b: B2) => void)) {} // If I swap the two types it compiles
Expected behavior:
No errors.
Actual behavior:
TS2345: Argument of type '(a: A1, b: B1) => void' is not assignable to parameter of type '((x: number, a: B1, b: B1) => void) | ((a: B1, b: B1) => void)'.
Type '(a: A1, b: B1) => void' is not assignable to type '(x: number, a: B1, b: B1) => void'.
Types of parameters 'a' and 'x' are incompatible.
Type 'number' is not assignable to type 'A1'.
Related Issues:
I looked around and didn't anything obviously related.
Activity