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
Signatures with less parameters aren't assignable to compatible targets with more when their rest param is an instantiated NoInferΒ #59668
declarefunctioncall<Aextendsreadonlyunknown[]>(arg: (...args: NoInfer<A>)=>void,
...args: A): A;// Argument of type '(a: number) => void' is not assignable to parameter of type '(...args: NoInfer<[number, number]>) => void'.// Types of parameters 'a' and 'args' are incompatible.// Type '[number, number]' is not assignable to type '[a: number]'.// Source has 2 element(s) but target allows only 1.(2345)constinferred=call((a: number)=>{},1,2);// ^? function call<[number, number]>(arg: (...args: NoInfer<[number, number]>) => void, args_0: number, args_1: number): [number, number]declarefunctioncall2<Aextendsreadonlyunknown[]>(arg: (...args: A)=>void,
...args: A): A;constinferred2=call2<[number,number]>((a: number)=>{},1,2);// ^? const inferred2: [number, number]
π Actual behavior
The first call fails to typecheck
π Expected behavior
Both of those calls use the same arguments. The first one is using NoInfer so the covariant inference can get prioritized. That prevents the instantiated signature from typechecking like the second one. Note that the first call infers the same type argument as the one that is supplied explicitly to the second call: [number, number]
Additional information about the issue
I think that this can be fixed by normalizing NoInfer<[A, B]> to [NoInfer<A>, NoInfer<B>]. This would be similar to what instantiateMappedTupleType does today at times.
Activity
imhele commentedon Aug 24, 2024
maybe this would be better?
https://www.typescriptlang.org/play/?ts=5.6.0-dev.20240817#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXzCgggB4BBeEADwxFWAGd44pg8IBPeNAa1RwDuqANoBdAHwAKAFDx4sAOYAueADkcASVSIQMEpIB0RxQxVkAlPAC84+ADccWYOIA0s+EYMmz082YDc0mB4DBjwWNq6cMDWBEQQkpJQKqjIALYARrqWNvAA3gC+LvAAjMUATOaBAPTVcvUNjfAAegD80tKgkLAIKOjYeHHE5eSUNHSMzCCs7Fy8-EJiUu6KKobGMAqm8BbWtg5ObnKe3ju+AUEhYRE6MNHlsYTDJMKpmbrFb1kwEonJ8F9snt8kVShUqtJag02tIgA
jcalz commentedon Dec 25, 2024
I just ran into this.