Skip to content

Commit

Permalink
Fix union type flattened error type
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin McDonnell committed Mar 2, 2022
1 parent 363937b commit 6cadd62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ export type ZodTypeAny = ZodType<any, any, any>;
export type TypeOf<T extends ZodType<any, any, any>> = T["_output"];
export type input<T extends ZodType<any, any, any>> = T["_input"];
export type output<T extends ZodType<any, any, any>> = T["_output"];

type allKeys<T> = T extends any ? keyof T : never;
export type TypeOfFlattenedError<
T extends ZodType<any, any, any>,
U = string
> = {
formErrors: U[];
fieldErrors: {
[P in keyof TypeOf<T>]?: U[];
[P in allKeys<TypeOf<T>>]?: U[];
};
};
export type TypeOfFormErrors<
Expand Down
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ export type ZodTypeAny = ZodType<any, any, any>;
export type TypeOf<T extends ZodType<any, any, any>> = T["_output"];
export type input<T extends ZodType<any, any, any>> = T["_input"];
export type output<T extends ZodType<any, any, any>> = T["_output"];

type allKeys<T> = T extends any ? keyof T : never;
export type TypeOfFlattenedError<
T extends ZodType<any, any, any>,
U = string
> = {
formErrors: U[];
fieldErrors: {
[P in keyof TypeOf<T>]?: U[];
[P in allKeys<TypeOf<T>>]?: U[];
};
};
export type TypeOfFormErrors<
Expand Down

0 comments on commit 6cadd62

Please sign in to comment.