ParseFunction: {
    <T extends ZodType<any, ZodTypeDef, any>>(
        data: TypeOf<T>,
        envelope: undefined,
        schema: T,
        safeParse?: false,
    ): TypeOf<T>;
    <T extends ZodType<any, ZodTypeDef, any>>(
        data: TypeOf<T>,
        envelope: undefined,
        schema: T,
        safeParse: true,
    ): ParsedResult<TypeOf<T>>;
    <T extends ZodType<any, ZodTypeDef, any>, E extends Envelope>(
        data: unknown,
        envelope: E,
        schema: T,
        safeParse?: false,
    ): E extends ArrayEnvelope ? TypeOf<T>[] : TypeOf<T>;
    <T extends ZodType<any, ZodTypeDef, any>, E extends Envelope>(
        data: unknown,
        envelope: E,
        schema: T,
        safeParse: true,
    ): E extends ArrayEnvelope
        ? ParsedResult<unknown, TypeOf<T>[]>
        : ParsedResult<unknown, TypeOf<T>>;
    <
        T extends ZodType<any, ZodTypeDef, any>,
        E extends Envelope,
        S extends boolean = false,
    >(
        data: unknown,
        envelope: E,
        schema: T,
        safeParse?: S,
    ): S extends true
        ? E extends ArrayEnvelope
            ? ParsedResult<unknown, TypeOf<T>[]>
            : ParsedResult<unknown, TypeOf<T>>
        : E extends ArrayEnvelope ? TypeOf<T>[] : TypeOf<T>;
}

The parser function that can parse the data using the provided schema and envelope we use function overloads to provide the correct return type based on the provided envelope

Type declaration

    • <T extends ZodType<any, ZodTypeDef, any>>(
          data: TypeOf<T>,
          envelope: undefined,
          schema: T,
          safeParse?: false,
      ): TypeOf<T>
    • Type Parameters

      • T extends ZodType<any, ZodTypeDef, any>

      Parameters

      • data: TypeOf<T>
      • envelope: undefined
      • schema: T
      • OptionalsafeParse: false

      Returns TypeOf<T>

    • <T extends ZodType<any, ZodTypeDef, any>>(
          data: TypeOf<T>,
          envelope: undefined,
          schema: T,
          safeParse: true,
      ): ParsedResult<TypeOf<T>>
    • Type Parameters

      • T extends ZodType<any, ZodTypeDef, any>

      Parameters

      • data: TypeOf<T>
      • envelope: undefined
      • schema: T
      • safeParse: true

      Returns ParsedResult<TypeOf<T>>

    • <T extends ZodType<any, ZodTypeDef, any>, E extends Envelope>(
          data: unknown,
          envelope: E,
          schema: T,
          safeParse?: false,
      ): E extends ArrayEnvelope ? TypeOf<T>[] : TypeOf<T>
    • Type Parameters

      • T extends ZodType<any, ZodTypeDef, any>
      • E extends Envelope

      Parameters

      • data: unknown
      • envelope: E
      • schema: T
      • OptionalsafeParse: false

      Returns E extends ArrayEnvelope ? TypeOf<T>[] : TypeOf<T>

    • <T extends ZodType<any, ZodTypeDef, any>, E extends Envelope>(
          data: unknown,
          envelope: E,
          schema: T,
          safeParse: true,
      ): E extends ArrayEnvelope
          ? ParsedResult<unknown, TypeOf<T>[]>
          : ParsedResult<unknown, TypeOf<T>>
    • Type Parameters

      • T extends ZodType<any, ZodTypeDef, any>
      • E extends Envelope

      Parameters

      • data: unknown
      • envelope: E
      • schema: T
      • safeParse: true

      Returns E extends ArrayEnvelope
          ? ParsedResult<unknown, TypeOf<T>[]>
          : ParsedResult<unknown, TypeOf<T>>

    • <
          T extends ZodType<any, ZodTypeDef, any>,
          E extends Envelope,
          S extends boolean = false,
      >(
          data: unknown,
          envelope: E,
          schema: T,
          safeParse?: S,
      ): S extends true
          ? E extends ArrayEnvelope
              ? ParsedResult<unknown, TypeOf<T>[]>
              : ParsedResult<unknown, TypeOf<T>>
          : E extends ArrayEnvelope ? TypeOf<T>[] : TypeOf<T>
    • Type Parameters

      • T extends ZodType<any, ZodTypeDef, any>
      • E extends Envelope
      • S extends boolean = false

      Parameters

      • data: unknown
      • envelope: E
      • schema: T
      • OptionalsafeParse: S

      Returns S extends true
          ? E extends ArrayEnvelope
              ? ParsedResult<unknown, TypeOf<T>[]>
              : ParsedResult<unknown, TypeOf<T>>
          : E extends ArrayEnvelope ? TypeOf<T>[] : TypeOf<T>