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
typeNumbers=[a: number,b: number];typeStrings=[a: string,b: string];typeTupleArgs=(...args: Numbers)=>void;constf1: TupleArgs=(a)=>console.log(a);// πtypeSignatureOverload={(...args: Numbers): void;(...args: Strings): void;}typeFnsIntersection=((...args: Numbers)=>void)&((...args: Strings)=>void);typeTuplesUnionArgs=(...args: Numbers|Strings)=>void;constf2: SignatureOverload=(a)=>console.log(a);// πconstf3: FnsIntersection=(a)=>console.log(a);// πconstf4: TuplesUnionArgs=(a)=>console.log(a);// β/** * Type '(a: string | number) => void' is not assignable to type 'TuplesUnionArgs'. * Types of parameters 'a' and 'args' are incompatible. * Type 'Numbers | Strings' is not assignable to type '[a: string | number]'. * Type 'Numbers' is not assignable to type '[a: string | number]'. * Source has 2 element(s) but target allows only 1.(2322) */
π Actual behavior
Type '(a: string | number) => void' is not assignable to type 'TuplesUnionArgs'.
Types of parameters 'a' and 'args' are incompatible.
Type 'Numbers | Strings' is not assignable to type '[a: string | number]'.
Type 'Numbers' is not assignable to type '[a: string | number]'.
Source has 2 element(s) but target allows only 1. (2322)
π Expected behavior
(a: string | number) => void should be assignable to (...args: [a: number, b: number] | [a: string, b: string]) => void
Additional information about the issue
Since this issue has 2 pretty clean workarounds (signature overload, functions intersection), it is not critical.
But it is an instance of inconsistent behaviour (which is annoying).
The text was updated successfully, but these errors were encountered:
π Search Terms
"tuple union" "tuple spread"
π Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ for entries about
β― Playground Link
Playground Link
π» Code
π Actual behavior
π Expected behavior
(a: string | number) => void
should be assignable to(...args: [a: number, b: number] | [a: string, b: string]) => void
Additional information about the issue
Since this issue has 2 pretty clean workarounds (signature overload, functions intersection), it is not critical.
But it is an instance of inconsistent behaviour (which is annoying).
The text was updated successfully, but these errors were encountered: