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
I've read through the related issues and the origin behind this error message, but I still can't wrap my head around this particular case, and it feels like a bug to me. In particular, this feels extra weird because the issue goes away if I just add an extra generic parameter on the interface - even though they are really doing the same thing.
It feels like TypeScript should be able to figure out, that if I pass e.g. Hello1<(a: number) => void> to whoops(), then it should be able to resolve C into (a: number) => void and A into [number]. And if, for some reason, the callee specifies an incompatible set of generics to the functions, that is should fail then, instead of at the function definition.
There are some variations I've tried on the exact signature of the function, but I haven't found anything that works.
Expected behavior: Both examples compile.
Actual behavior: Only one example compiles. The other fails with:
Type 'C' does not satisfy the constraint '(...args: any[]) => void'.
Type '(...args: A) => void' is not assignable to type '(...args: any[]) => void'.
Types of parameters 'args' and 'args' are incompatible.
Type 'any[]' is not assignable to type 'A'.
'any[]' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype of constraint 'any[]'.
TypeScript Version: 3.7.2
Search Terms:
I've read through the related issues and the origin behind this error message, but I still can't wrap my head around this particular case, and it feels like a bug to me. In particular, this feels extra weird because the issue goes away if I just add an extra generic parameter on the interface - even though they are really doing the same thing.
It feels like TypeScript should be able to figure out, that if I pass e.g.
Hello1<(a: number) => void>
towhoops()
, then it should be able to resolveC
into(a: number) => void
andA
into[number]
. And if, for some reason, the callee specifies an incompatible set of generics to the functions, that is should fail then, instead of at the function definition.There are some variations I've tried on the exact signature of the function, but I haven't found anything that works.
Expected behavior: Both examples compile.
Actual behavior: Only one example compiles. The other fails with:
Related Issues: #29049
Code
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: