Hello, I've noticed that the mapped-type when formatting an error is not reused in the recursive type.
This causes the “sub-levels” _errors of an object to be incorrectly typed.
Here's an example:
declare const error: z.ZodError<{ flat: number; object: { nested: number } }>;
const formatted = error.format(issue => !!issue.fatal);
const ok: boolean[] = formatted._errors ?? [];
// Type 'string[]' is not assignable to type 'boolean[]'
const ko1: boolean[] = formatted.flat?._errors ?? [];
// Type 'string[]' is not assignable to type 'boolean[]'
const ko2: boolean[] = formatted.object?.nested?._errors ?? [];
I solved the problem locally on my end and will probably submit a “PR” soon.
Hello, I've noticed that the mapped-type when formatting an error is not reused in the recursive type. This causes the “sub-levels”
_errors
of an object to be incorrectly typed.Here's an example:
I solved the problem locally on my end and will probably submit a “PR” soon.