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 get has no compatible call signature error when invoking a method defined by interface that every variant of type union implements.
Here is an example code also included inline below for convenience. I am afraid it's little verbose but I could not think of ways to reduce it further:
I would expect this code to type check fine given that both Ok and Err implement IResult interface that defines map method map <b> (f:(input:a) => b):Result<x, b>.
Actual behavior:
tsc reports following error:
Cannot invoke an expression whose type lacks a call signature. Type (<b>(f: (value: a) => b) => Ok<b>) | (<b>(f: (value: any) => b) => Err<x>) has no compatible call signatures.
(parameter) result: Ok<a> | Err<x>
** Workaround: **
It is possible to workaround this issue by down-casting passed result to IResult<x, a>:
(<IResult<x,a>>result).map(f)
But that means every user of the Result library will have to acknowledged this workaround and use it in their code if they happen to do something other that what's provided by a library.
The text was updated successfully, but these errors were encountered:
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.3 / nightly (2.2.0-dev.201xxxxx)
I get
has no compatible call signature
error when invoking a method defined by interface that every variant of type union implements.Here is an example code also included inline below for convenience. I am afraid it's little verbose but I could not think of ways to reduce it further:
Expected behavior:
I would expect this code to type check fine given that both
Ok
andErr
implementIResult
interface that defines map methodmap <b> (f:(input:a) => b):Result<x, b>
.Actual behavior:
tsc reports following error:
** Workaround: **
It is possible to workaround this issue by down-casting passed
result
toIResult<x, a>
:But that means every user of the
Result
library will have to acknowledged this workaround and use it in their code if they happen to do something other that what's provided by a library.The text was updated successfully, but these errors were encountered: