neverthrow
neverthrow copied to clipboard
Type-Safe Errors for JS & TypeScript
I'm new to this topic and started experimenting. I realized that I'm missing some helper methods for cases of `Result`. Implementing my own result for educational purpose resulted in the...
The goal of this change is to remove the `> ` from the npm install commands in the README that break the quick copy/paste feature that GitHub now offers. We...
Fixes #616. Currently functions `map` and `mapErr` cannot receive callbacks that return type `A | Promise`, because the callback is expected to have return type `A | Promise`. This PR...
Those functions cannot receive callbacks that return type `A | Promise`. Reproduction for `map` ([playground](https://www.typescriptlang.org/play/?#code/CYUwxgNghgTiAEkoGdnwEomQVwgFwEFkBPAOzAB4AVAGngFEA+eAbwCh5P4BbKABwoFGACgBmALnjC8kqgEp4AXmYF4AH3gAFGAHtuAS2QhBjOZMw58RMpQJ0mAbjYBfNm1BI48UdnJ59OqQ8-HwgMMIAHpLIeDD6pADmZvCk2NwARmHqWroGRhQxcYmMTh7QXmCBMfBRGFi4hCTkBbHxCXSkIABuYSVulaTVcJZ4SjUAdLx8wlOhMHIOQA)): ```typescript declare class ResultAsync { map(f: (t: T) => A | Promise): ResultAsync; } declare...
Since in these cases, `isOk()` returns a static bool, there is no need to call it.
When using `ResultAsync.fromThrowable`, there can be some weird typing mishaps that happen with functions that have multiple overloads. An example of this bug(?) is `readFile` imported from `node:fs/promises`. When `readFile`...
``` import { getLines } from 'imaginary-parser' // ^ assume getLines has the following signature: // getLines(str: string): Result // since the formatting is deemed correct by `getLines` // then...
There's a tiny typo in the async code example of https://github.com/supermacro/neverthrow/wiki/Basic-Usage-Examples Actual: seconds argument Expected: second argument