Skip to content

Commit

Permalink
Fix catchall types
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhacks committed Mar 21, 2024
1 parent b4209c8 commit b941914
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2193,11 +2193,11 @@ export type baseObjectInputType<Shape extends ZodRawShape> =
[k in keyof Shape]: Shape[k]["_input"];
}>;

export type CatchallOutput<T extends ZodTypeAny> = ZodTypeAny extends T
export type CatchallOutput<T extends ZodType> = ZodType extends T
? unknown
: { [k: string]: T["_output"] };

export type CatchallInput<T extends ZodTypeAny> = ZodTypeAny extends T
export type CatchallInput<T extends ZodType> = ZodType extends T
? unknown
: { [k: string]: T["_input"] };

Expand Down
3 changes: 3 additions & 0 deletions playground.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { z, ZodNativeEnum } from "./src";

z;

const A = z.object({}).catchall(z.string());
type A = z.infer<typeof A>;
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2193,11 +2193,11 @@ export type baseObjectInputType<Shape extends ZodRawShape> =
[k in keyof Shape]: Shape[k]["_input"];
}>;

export type CatchallOutput<T extends ZodTypeAny> = ZodTypeAny extends T
export type CatchallOutput<T extends ZodType> = ZodType extends T
? unknown
: { [k: string]: T["_output"] };

export type CatchallInput<T extends ZodTypeAny> = ZodTypeAny extends T
export type CatchallInput<T extends ZodType> = ZodType extends T
? unknown
: { [k: string]: T["_input"] };

Expand Down

0 comments on commit b941914

Please sign in to comment.