neverthrow
neverthrow copied to clipboard
Type-Safe Errors for JS & TypeScript
Hi, created this to run side effects like logging. Name "tap" is inspired by [rxjs tap](https://www.learnrxjs.io/learn-rxjs/operators/utility/do)
https://github.com/supermacro/neverthrow/pull/500#issuecomment-1781429816 Some errors are reproduced in `tests/safe-try.test.ts`. This PR is not intended to be merged, but only for sharing reproduced error cases.
`combineWithAllErrors` provides types that are not necessarily correct. ```typescript const foo: Result = ok("a"); const bar: Result = err("d"); Result.combineWithAllErrors([foo, bar]).mapErr((errors) => { errors satisfies ["b", "d"]; // should NOT...
When writing a match in neverthrow, the `ok` and `err` callbacks _must_ have the same `ReturnType` in their signature. This means the following code results in an error ```typescript declare...
Hey everyone ... I want to apologize for disappearing here on the `neverthrow` repo for a few months. I did not have the time to focus on this project -...
Getting ERR_UNHANDLED_REJECTION when using fromPromise to read non-existent files. ` import { readFile } from 'node:fs/promises'; public read(path: string): ResultAsync { const res = ResultAsync.fromPromise( readFile(path, 'utf8'), (e) => new...
I have a parent function that returns a resultasync as it executes at least one async child function. the two child functions to chain return a Result and a ResultAsync...
I really like the idea of type-safe errors but still struggle on how to correctly define them in interfaces. Let's say I have the following interface for an AI prompt...
First off, as a rust developer, this library makes node development so much more fun and ergonomic. However, and you are probably aware, there are still some limits that I...
Hey , any recommendations on how to do the following pattern in a route handler, hopefully the pseudo code makes sense: ``` (req, res, next) => { loadUser(req) .andThen(validateUser) .andThen(lookupCache)...