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
// Assuming ErrorA and ErrorB are structurally different.result.chain(value=>{if(value<0)returnerr(newErrorB());elsereturnok(value);});
then I get the error:
TS2345: Argument of type (value: number) => Result<number, ErrorA> | Result<never, ErrorB> is
not assignable to parameter of type (value: number) => Result<number, ErrorA>
Type Result<number, ErrorA> | Result<never, ErrorB> is not assignable to type
Result<number, ErrorA>
Type Ok<never, ErrorB> is not assignable to type Result<number, ErrorA>
Type Ok<never, ErrorB> is not assignable to type Ok<number, ErrorA>
Property x is missing in type ErrorB but required in type ErrorA
It seems like it is not possible to switch error type inside a chain with only a ok-mapper. The only workaround is:
Let's say I have the following result:
and I want to chain like this:
then I get the error:
It seems like it is not possible to switch error type inside a chain with only a ok-mapper. The only workaround is:
but that is clearly too verbose.
The text was updated successfully, but these errors were encountered: