Handling Error Types When Forking Effects in TypeScript

When I want to run an effect in a separate fiber, but want the controlling effect to return the same signature as the effect it forks, how can I do that? The success case works fine, but I am not able to return the error type correctly

const someOperation: Effect.Effect<number, Error, never> = Effect.succeed(5)
const program: Effect.Effect<number, Error, never> = Effect.gen(function* () {
  const fiber = yield* someOperation.pipe(Effect.fork);
  const exit = yield* Fiber.await(fiber);

  if (Exit.isSuccess(exit)) {
    return exit.value;
  } else {
    // what do I return here? how do I handle the error type
    return 
  }
})
Was this page helpful?