Skip to content

Latest commit

 

History

History
31 lines (28 loc) · 1.76 KB

File metadata and controls

31 lines (28 loc) · 1.76 KB

Migration

unthrown@4.x5.0

The full, worked guide lives in the docs: Upgrade from 4.x to 5.0. The headline breaking surface, so you have it up front:

  • Error combinators renamed with a …Cases suffix (each takes an exhaustive matcher): mapErrmapErrCases, flatMapErrflatMapErrCases, recoverErrrecoverErrCases, tapErrtapErrCases, flatTapErrflatTapErrCases.
  • match's error handler renamed errerrCases (it takes the matcher, not the error value). This one was a silent runtime break in the first betas — a leftover err: handler that threw compiled and then threw the matcher object; the renamed key makes it an excess-property compile error.
  • Removed 4.x aliases: unwrap / unwrapErr / unwrapOr / unwrapOrElse (use get / getErr / getOr / getOrElse), orElse / recover (use flatMapErrCases / recoverErrCases), and matchTags / the TagHandlers type (use match({ …, errCases: (m) => m.with(P.tag("…"), …) })).
  • Renamed export: UnwrapErrorGetError.
  • getOrThrow() is now gated to a non-empty error channel; on a Result<T, never> use get().
  • The matcher is built-in — nothing to install alongside unthrown. (The early v5 betas took ts-pattern as a peer; the built-in matcher replaced it, keeping the same .with(…) / P call-site shape.)
  • @unthrown/pattern was absorbed into core — import match / P from unthrown.
  • Renamed: the standalone tag("…") pattern helper is now P.tag("…"), alongside every other pattern constructor. The old export is removed.
  • New: ensure, DoAsync, and the match / P re-exports.