From bd7312f860446b0a52df92491f86182d05ad016c Mon Sep 17 00:00:00 2001 From: Mendes Hugo <37412330+HugoMendes98@users.noreply.github.com> Date: Wed, 18 Sep 2024 20:27:03 +0000 Subject: [PATCH] fix: add the formatted type in `ZodFormattedError` type recursion --- src/ZodError.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ZodError.ts b/src/ZodError.ts index c1f7aa3ee..db36ccacd 100644 --- a/src/ZodError.ts +++ b/src/ZodError.ts @@ -177,17 +177,17 @@ export const quotelessJson = (obj: any) => { return json.replace(/"([^"]+)":/g, "$1:"); }; -type recursiveZodFormattedError = T extends [any, ...any[]] - ? { [K in keyof T]?: ZodFormattedError } +type recursiveZodFormattedError = T extends [any, ...any[]] + ? { [K in keyof T]?: ZodFormattedError } : T extends any[] - ? { [k: number]: ZodFormattedError } + ? { [k: number]: ZodFormattedError } : T extends object - ? { [K in keyof T]?: ZodFormattedError } + ? { [K in keyof T]?: ZodFormattedError } : unknown; export type ZodFormattedError = { _errors: U[]; -} & recursiveZodFormattedError>; +} & recursiveZodFormattedError, U>; export type inferFormattedError< T extends ZodType,