Handling Promise Rejection in Effect with React Component Integration

I'm looking for a terse way to recover from a failure with a Promise.reject in order to interop with a react component expecting a promise-returning function as a prop, and the following produces a wrong type: Promise<void | Promise<void> | undefined>

...,
Effect.match({
   onFailure: error => Promise.reject<void>(error.message),
   onSuccess: () => onSuccess?.()
}),
Effect.runPromise,


I think the following would fix it without messing up anything:
declare const runPromise: <A, E>(effect: Effect<A, E, never>, options?: {
    readonly signal?: AbortSignal;
} | undefined) => A extends Promise<any> ? A : Promise<A>;


I could use runPromiseExit, but since I don't need to comb through the causes it doesn't feel right.
Was this page helpful?