Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/zod/index.ts>z.ZodObject#merge

TypeScript-first schema validation with static type inference
Extremely Popular
Go to Latest
method z.ZodObject.prototype.merge
import { z } from "https://deno.land/x/zod@v3.20.5/index.ts";
const { ZodObject } = z;

Prior to zod@1.0.12 there was a bug in the inferred type of merged objects. Please upgrade if you are experiencing issues.

Type Parameters

Incoming extends AnyZodObject
Augmentation extends Incoming["shape"]
NewOutput extends [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation ? Augmentation[k]["_output"] : k extends keyof Output ? Output[k] : never
NewInput extends [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation ? Augmentation[k]["_input"] : k extends keyof Input ? Input[k] : never

Returns

ZodObject<extendShape<T, ReturnType<Incoming["_def"]["shape"]>>, Incoming["_def"]["unknownKeys"], Incoming["_def"]["catchall"], NewOutput, NewInput>