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.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Activity
gcanti commentedon May 23, 2017
AFAIK is a known limitation, see #7294 (comment)
The workaround I'm using in fp-ts is defining the same type parameters for both
OKandErrmhegazy commentedon Jun 7, 2017
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.