You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
Currently fromThrowable doesn't play well with functons that return a Promise:
fromThrowable(fnReturnPromise) => Result<Promise<Value>, Error> where we actually want Promise<Result<Value, Error>>
This could be solved as a seperate method, like fromThrowableAsync which accepts only Promise<T> returning functions, or maybe I can infer the return type statically, and then also correctly wrap the given fn to inspect it's return value and wrap if it's a promise accordingly (which would keep the library's API terse and simple).
The text was updated successfully, but these errors were encountered:
Solved by extending fromThrowable to support Promises, both with TypeScript type inferrence AND checking return type of wrapped function for potential Promise and then wrapping with ok and err respectively.
Currently
fromThrowable
doesn't play well with functons that return a Promise:fromThrowable(fnReturnPromise) => Result<Promise<Value>, Error>
where we actually wantPromise<Result<Value, Error>>
This could be solved as a seperate method, like
fromThrowableAsync
which accepts onlyPromise<T>
returning functions, or maybe I can infer the return type statically, and then also correctly wrap the given fn to inspect it's return value and wrap if it's a promise accordingly (which would keep the library's API terse and simple).The text was updated successfully, but these errors were encountered: