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
{{ message }}
Repository navigation
Union tuple type in rest argument can't accpect less argument.Β #48663
Type '(item: string | number) => void' is not assignable to type '(...args: [number, string] | [string, number]) => void'.
Types of parameters 'item' and 'args' are incompatible.
Type '[number, string] | [string, number]' is not assignable to type '[item: string | number]'.
Type '[number, string]' is not assignable to type '[item: string | number]'.
Source has 2 element(s) but target allows only 1.
I'm... not sure this is a duplicate of that, since there are no leading rest elements here to make the analysis weirder. Maybe the same underlying issue is happening in both places?
Anyway this one feels more like a bug to me, since the following is fine:
And while transitivity of assignability isn't the be-all and end-all for TypeScript, it's nice to be able to reason about things this way when possible.
I think the easiest way to solve all the related issues is to wrap all the arguments into a tuple with rest syntax, i.e. item => {} should become (...[item]) => {} and ([first, ...rest], foo, ...args) => {} should work just like (...[[first, ...rest], foo, ...args]) => {}.
Activity
MartinJohns commentedon Apr 13, 2022
Duplicate of #45972. Used search terms: `source has but target allows only"
jcalz commentedon Apr 13, 2022
I'm... not sure this is a duplicate of that, since there are no leading rest elements here to make the analysis weirder. Maybe the same underlying issue is happening in both places?
Anyway this one feels more like a bug to me, since the following is fine:
And while transitivity of assignability isn't the be-all and end-all for TypeScript, it's nice to be able to reason about things this way when possible.
graphemecluster commentedon May 29, 2022
Sorry to copy my #49218 (comment) here:
cdauth commentedon Jun 25, 2024
Not exactly the same issue, but probably the same root cause:
Also: