Zod utility to check if a schema is defined correctly against a given type

  • Type Parameters

    • T

    Returns <S extends ZodType<T, ZodTypeDef, unknown>>(
        schema: AssertEqual<S["_output"], T> extends true
            ? S
            : S & { "types do not match": { expected: T; received: S["_output"] } },
    ) => S