TypeScript Generics Issue with `yield*` in Generator Function

Hi guys! I am wondering if anyone can help me on this. I'm not sure why my typescript types are going wrong inside this generator function. The Error and Requirements generics are becoming unknown after I use a 'yield' on a Math.value operator. If I remove the yield the type errors disappear but the function does not work as intended. If anyone has any clues I would be very grateful! Thank you

const program = Effect.forEach(
    messages.results,
    (res) => {
      return Effect.gen(function* () {
......

    // when I remove yield the type errors disappear
   const messageId = yield* Match.value(res).pipe(
          Match.when({ message: { type: "TEXT" } }, (message) =>
            Effect.promise(() =>
              ctx.runMutation(internal.messages.insertMessage, {
                ...some mutation args
                },
              }),
            ),
          ),
        ....// other match.when statements very similar to the above

        Match.orElse((message) =>
            Effect.promise(() =>
              ctx.runMutation(internal.messages.insertMessage, {
                // ... some mutation args
              }),
            ),
          ),

......// some other code

        return yield* Effect.succeed({
          destinationId,
          messageId,
          channel,
        });
      });
    },
    {
      concurrency: "unbounded",
    },
  );
Screenshot_2024-12-02_at_3.07.28_PM.png
Was this page helpful?