zod
zod copied to clipboard
Fixed type Inference with `custom` and `instanceof` in `catchall`
Hello!
I noticed that when using custom
or instanceof
with catchall
, the type inference using infer
does not work.
I have fixed it and added tests.
Before
const schema = z.object({ name: z.string() }).catchall(z.instanceof(Date));
// { name: string }
type Schema = z.infer<typeof schema>;
After
const schema = z.object({ name: z.string() }).catchall(z.instanceof(Date));
// { name: string } & { [k: string]: Date };
type Schema = z.infer<typeof schema>;