Releases: everweij/typescript-result
Releases · everweij/typescript-result
3.5.3-beta.1
v3.5.3-beta.1 fixes type issue where `Result.Error<E>` and `Result.Ok<V>` is not in…
3.5.2
3.5.1
3.5.0
Minor changes:
-
Adds
match()
toResult
, introducing basic pattern matching to the lib. See docs for more info about this feature.declare const result: Result<number, ErrorA | ErrorB>; if (!result.ok) { result .match() .when(ErrorA, () => /* handle error a */) .when(ErrorB, () => /* handle error b */) .run() }
-
Adds
ok
property onResult
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 likets-pattern
. As a result,isOk()
andisError()
are marked for deprecation.declare const result: Result<number, ErrorA | ErrorB>; // before if (result.isError()) { result.error; // ErrorA | ErrorB } else { result.value; // number } // after if (!result.ok) { result.error; // ErrorA | ErrorB } else { result.value; // number }
-
Strings passed to
Result.error
are now constant:// before const result = Result.error("some-error"); // Result.Error<string> // after const result = Result.error("some-error"); // Result.Error<"some-error">;
3.5.0-beta.1
v3.5.0-beta.1 adds `match` functionality, simpler narrowing using `ok` (deprecating…
3.4.1
3.4.0
3.4.0-beta.2
v3.4.0-beta.2 separates result creation into own factory class
3.3.0
3.3.0-beta.2
v3.3.0-beta.2 adds overload to Result.gen and Result.genCatching for passing the th…