typescript-result
typescript-result copied to clipboard
A utility which helps you to write code that might fail in a declarative way
When running the following code: ``` function a(): Result { return Result.ok(0); } const x = a(); if (x.isSuccess()) { console.log(x.value); } ``` leads to null being printed. After looking...
Currently it seems not possible to chain operations if they are async. The following code does not work ```ts const example = await Result.combine(EntityId.create(id), EntityId.create(gameId)) .map( async ([id, gameId]) =>...
Sometimes, I use `SomeType | Result` as a parameter to function and I don't have a reliable way to check that value is a `Result`. To write code like this:...
Currently when you try to do something like this: ``` forgotPassword( data: ForgotPasswordDTO ): AsyncResult { if (...) { return Result.error(new UnexpectedError('Something went wrong')) } ... ``` you'll see an...
Results are awesome. Options are also nice. In Typescript they can be represented with a union of `T | undefined`, but there are no methods to map them. Adding them...
## Example 1 ```typescript const minimalRepro = ( fn: () => AsyncResult ): AsyncResult => { return Result.gen(function* () { const r = yield* fn(); return Result.ok(r); }) } ```...
```typescript const raise = (err: E): Result => Result.error(err) ``` Error: ```plain Type 'Error' is not assignable to type 'Error$1'. ``` Version: `[email protected]`
Hi! I've started using the li today, but when trying to run my tests started to get the error `"Property 'fromAsync' does not exist on type 'typeof ResultFactory'" `. My...
Why not add `Result.any` as the duality of `Result.all`, like `Promise.all` v.s. `Promise.any` and `Array#every` v.s. `Array#some`?