Closed braxtonhall closed 2 months ago
@supermacro Any updates on this? Would be really great to have this behavior for orElse
:)
+1
Latest commit: 378b3e530dd41ff6c2cb9a71e8b9c0b5feacc74e
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
It is possible to make this PR not a breaking change
- orElse<U, A>(f: (e: E) => Result<U, A> | ResultAsync<U, A>): ResultAsync<U | T, A>
+ orElse<A, U = T>(f: (e: E) => Result<U, A> | ResultAsync<U, A>): ResultAsync<U | T, A>
That way anyone who has already explicitly annotated the type arguments res.orElse<Foo>(..)
will have the same behaviour as before.
The downside is of course that this is really awkward to use, especially as it swaps the order or the ok value type and the err value type. I would guess that would be super error prone and surprising to users.
Unfortunately this would be a breaking change, as anyone who explicitly annotated the types like
orElse<A>(foo)
will need to update their code toorElse<U, A>(foo)