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
expectTypeOf(foo).toBeCallableWith("abc","efg");~~~~~Argumentoftype'string'isnotassignabletoparameteroftype'number'.expectTypeOf(foo).toBeCallableWith(123,456);foo("abc","efg");// but all is good herefoo(123,456);
Hm.. If a simple foo() does the job (and does it better!), what is the purpose of .toBeCallableWith()? I mean, .toEqualTypeOf() works perfectly in both of the cases I mentioned above:
.not.toBeCallableWith() could handle a check which .toEqualTypeOf() cannot and would be more useful than // @ts-expect-error. Unfortunately it is not implemented at the moment.
The text was updated successfully, but these errors were encountered:
Hm.. If a simple foo() does the job (and does it better!), what is the purpose of .toBeCallableWith()? I mean, .toEqualTypeOf() works perfectly in both of the cases I mentioned above:
Yeah, I sometimes regret adding toBeCallableWith for this reason. The advantages of it:
It's more explicit - it says "I am testing that this function accepts these parameters" rather than expectTypeOf(foo(...)).toEqualTypeOf<...>() which looks more like "I am testing that this function has this return type".
It doesn't involve actually calling the function, which may have side-effects.
But outside of those, you're probably better off with foo(...) in this case.
I’m leaving the issue open in case you would like to document the limitation with overloaded and generic functions. Feel free to close, if that does not look significant.
If a generic function is declared like this:
The
.toBeCallableWith()
matcher fails:Testing an overloaded function:
Does not work either:
Hm.. If a simple
foo()
does the job (and does it better!), what is the purpose of.toBeCallableWith()
? I mean,.toEqualTypeOf()
works perfectly in both of the cases I mentioned above:.not.toBeCallableWith()
could handle a check which.toEqualTypeOf()
cannot and would be more useful than// @ts-expect-error
. Unfortunately it is not implemented at the moment.The text was updated successfully, but these errors were encountered: