From b9419146fc8c92b68375303c79c995cdef5df261 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Thu, 21 Mar 2024 16:34:44 -0700 Subject: [PATCH] Fix catchall types --- deno/lib/types.ts | 4 ++-- playground.ts | 3 +++ src/types.ts | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/deno/lib/types.ts b/deno/lib/types.ts index 23c2bb6f7..279f4e44b 100644 --- a/deno/lib/types.ts +++ b/deno/lib/types.ts @@ -2193,11 +2193,11 @@ export type baseObjectInputType = [k in keyof Shape]: Shape[k]["_input"]; }>; -export type CatchallOutput = ZodTypeAny extends T +export type CatchallOutput = ZodType extends T ? unknown : { [k: string]: T["_output"] }; -export type CatchallInput = ZodTypeAny extends T +export type CatchallInput = ZodType extends T ? unknown : { [k: string]: T["_input"] }; diff --git a/playground.ts b/playground.ts index 418f1fc8a..6e008be42 100644 --- a/playground.ts +++ b/playground.ts @@ -1,3 +1,6 @@ import { z, ZodNativeEnum } from "./src"; z; + +const A = z.object({}).catchall(z.string()); +type A = z.infer; diff --git a/src/types.ts b/src/types.ts index 983f66014..6a3e4d203 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2193,11 +2193,11 @@ export type baseObjectInputType = [k in keyof Shape]: Shape[k]["_input"]; }>; -export type CatchallOutput = ZodTypeAny extends T +export type CatchallOutput = ZodType extends T ? unknown : { [k: string]: T["_output"] }; -export type CatchallInput = ZodTypeAny extends T +export type CatchallInput = ZodType extends T ? unknown : { [k: string]: T["_input"] };