From 6cadd62ae2064ccfd02c5f29761c48db5a3fc15f Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Tue, 1 Mar 2022 12:38:59 -0800 Subject: [PATCH] Fix union type flattened error type --- deno/lib/types.ts | 4 +++- src/types.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/deno/lib/types.ts b/deno/lib/types.ts index e06b498a0..060bf6128 100644 --- a/deno/lib/types.ts +++ b/deno/lib/types.ts @@ -50,13 +50,15 @@ export type ZodTypeAny = ZodType; export type TypeOf> = T["_output"]; export type input> = T["_input"]; export type output> = T["_output"]; + +type allKeys = T extends any ? keyof T : never; export type TypeOfFlattenedError< T extends ZodType, U = string > = { formErrors: U[]; fieldErrors: { - [P in keyof TypeOf]?: U[]; + [P in allKeys>]?: U[]; }; }; export type TypeOfFormErrors< diff --git a/src/types.ts b/src/types.ts index 62fd0fa37..b306f13fb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -50,13 +50,15 @@ export type ZodTypeAny = ZodType; export type TypeOf> = T["_output"]; export type input> = T["_input"]; export type output> = T["_output"]; + +type allKeys = T extends any ? keyof T : never; export type TypeOfFlattenedError< T extends ZodType, U = string > = { formErrors: U[]; fieldErrors: { - [P in keyof TypeOf]?: U[]; + [P in allKeys>]?: U[]; }; }; export type TypeOfFormErrors<