Unexpected Error Type in signInWithUsername Effect

Can someone help me determine why this Effect has a return type with just Error as the errors instead of what I would expect to be propagated from the Effect.gen()

const signInWithUsername: (input: {
    username: string;
    password: string;
}) => Effect.Effect<never, Error, never>
// expected => Effect.Effect<never, AccountNotFoundError | UserNotFoundError | MissingPasswordHashError | IncorrectPasswordError | ... , never>




const signInWithUsername = (input: {
      username: string;
      password: string;
    }) =>
      Effect.gen(function* (_) {
        const account = Option.getOrThrowWith(
          yield* userService.getAccountByUsername(input.username),
          () =>
            new AccountNotFoundError(
              `Account with username: ${input.username} not found`,
            ),
        );

        const user = Option.getOrThrowWith(
          yield* userService.getUserById(account.userId),
          () =>
            new UserNotFoundError(
              `User for accountId: ${account.id}, username: ${input.username}, userId ${account.userId} not found`,
            ),
        );

        if (account.passwordHash == null) {
          yield* Effect.fail(
            new MissingPasswordHashError(
              `Account ${account.id} is missing a password hash`,
            ),
          );
        }

        const validPassword = yield* verifyPassword(
          account.passwordHash!,
          input.password,
        );
        if (!validPassword) {
          yield* Effect.fail(new IncorrectPasswordError("Incorrect password"));
        }

        const session = yield* createSession(user.id);

        const sessionCookie = yield* Effect.promise(async () =>
          lucia.createSessionCookie(session.id),
        );

        cookies().set(
          sessionCookie.name,
          sessionCookie.value,
          sessionCookie.attributes,
        );
        return redirect("/");
      });
Was this page helpful?