The Result type addresses the lack of statically typed thrown errors in TypeScript, offering a way to model success and failure in a function's return value.
Libraries like neverthrow, effect-ts, and fp-ts provide this functionality, with trade-offs in simplicity, maintenance, complexity, and bundle size.
@praha/byethrow is a new library focused on the Result type, aiming to be simple, tree-shakable, and lightweight.
It represents Result values as plain objects, allowing safe serialization to JSON and easy processing at server-client boundaries.
@praha/byethrow's unified API, both synchronous and asynchronous, offers a consistent interface for handling results.
The library provides well-documented functions with TSdoc-based examples and an online API reference for quick adoption.
Usage scenarios are discussed, emphasizing the need for handling expected errors predictably with Result while allowing other exceptions to be thrown and logged.
@praha/byethrow caters to developers seeking type-safe error handling without the complexity of existing libraries like neverthrow, effect-ts, or fp-ts.
The library is recommended for those finding other options lacking or overly heavy, and users are encouraged to support the project by starring the repository.