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
See #19 - Fixes issue where TS had trouble inferring the Result value when the shape of a value has some structural overlap with a Result type (e.g. { value: string }.
Adds match() to Result, introducing basic pattern matching to the lib. See docs for more info about this feature.
declareconstresult: Result<number,ErrorA|ErrorB>;if(!result.ok){result.match().when(ErrorA,()=>/* handle error a */).when(ErrorB,()=>/* handle error b */).run()}
Adds ok property on Result as the main way to check whether a result is a success or failure. See updated docs. This makes error handling a bit simpler, and allows us to more easily use a result with a pattern-matching lib like ts-pattern. As a result, isOk() and isError() are marked for deprecation.
See #18 - Due to an @internal annotation, the generator syntax (yield*, etc) wasn't working correctly. Removing the annotations on [Symbol.iterator]() solved the issue.
See #16: we better narrow Result.Ok / Result.Error when using Result.isOk() and Result.isError().
Fixes
See #17: we now ignore any mapped values when a result can only be a failure, and likewise ignore the returned value when recovering from results that can only be successful.