Issue with inferring ErrorType in generator function using Effect library

generator function not infering correct ErrorType in return.
import { AuditLogAction, AuditLogStatus } from "@/db/schemas/auditLogs";
import { Logging } from "@/lib/effects/services/logging";
import { ValidationError } from "@/types/errors";
import { Effect } from "effect";
import type { ZodSchema } from "zod";

export const parseWithEffect = <T>(schema: ZodSchema<T>, input: unknown) =>
    Effect.gen(function* () {
        const logging = yield* Logging;
        const result = schema.safeParse(input);

        if (!result.success) {
            yield* logging.logStep({
                event: "Validate data",
                action: AuditLogAction.enum.EXECUTE,
                status: AuditLogStatus.enum.FAILURE,
                metadata: result.error,
            });
            return yield* Effect.fail(
                new ValidationError("Validation failed", { cause: result.error }),
            );
        }

        yield* logging.logStep({
            event: "Validate data",
            action: AuditLogAction.enum.EXECUTE,
            status: AuditLogStatus.enum.SUCCESS,
        });

        return result.data;
    });

I'd like this to infer Effect.Effect<T, ValidationError, Logging> but there must be an issue w/ my syntax. Does anyone know?
Was this page helpful?