You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// ConditionalTuple could also return just [] in the false branch, issue still reprostypeConditionalTuple<T>=[T]extends[undefined] ? [] : [T];// works fine!declarevarf1: (...args: any[])=>void;declarevarf2: <T>(...args: ConditionalTuple<T>)=>void;declarevarf3: (...args: ConditionalTuple<number>)=>void;f2=f1;f3=f1;// but if we move the signatures above into a callback parameter with that signature,// assignability breaks - the types of cb are incompatible.declarevarcb1: (cb: (...args: any[])=>void)=>void;declarevarcb2: <T>(cb: (...args: ConditionalTuple<T>)=>void)=>void;declarevarcb3: (cb: (...args: ConditionalTuple<number>)=>void)=>void;cb2=cb1;// can't assign to cb2cb3=cb1;// this works though
Expected behavior:
I am able to construct callback signatures with generic conditional types and tuples that are assignable with the maximally general callback signature (cb1).
Actual behavior: cb1 cannot be assigned to cb2, but removing the generic parameter ala cb3 makes assignability work as expected.
TypeScript Version: 3.1.0-dev.20180727
Code
Expected behavior:
I am able to construct callback signatures with generic conditional types and tuples that are assignable with the maximally general callback signature (
cb1).Actual behavior:
cb1cannot be assigned tocb2, but removing the generic parameter alacb3makes assignability work as expected.