Fix not being able to call Result's or and orElse methods #188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The error solved here:
The same issue existed in both implementations and the fix is basically the same.
There are two aspects of this patch, one I'm pretty confident about and the other remains an open question:
To expand on the latter point, for example let's say we have
then the type of final could be, in principle, one of these:
a. Result<number, string>
b. Result<number, never>
c. Ok
We know it's going to be Ok but I'm not entirely sure it should be reflected in the type because I can totally see this kind of type narrowing resulting in losing precious type information in the client code where someone would like to maintain a Result<T, E> context and not have it narrowed down to Ok.
I'm not very confident about that but that's my prediction.
Therefore I went with that expression evaluating to option b (Result<number, never>) to at least remain in the Result context and the implementation of this is simple enough.
Also I feel that the case where the "other" result is gonna be statically known to always be Ok is going to be an edge case we don't have to worry about.
If this proves to be a problem let's revisit the issue.
Resolves: #175