1- import { unique } from '../../utils'
1+ import { unique , ValueOf } from '../../utils'
22import {
33 ZodArray ,
44 ZodEnum ,
@@ -49,7 +49,8 @@ export type mergeTypes<A, B> = {
4949export type objectOutputType <
5050 Shape extends ZodRawShape ,
5151 UnknownKeys extends UnknownKeysParam = UnknownKeysParam ,
52- > = objectUtil . flatten < objectUtil . addQuestionMarks < baseObjectOutputType < Shape > > > & UnknownKeysOutputType < UnknownKeys >
52+ > = UnknownKeysOutputType < UnknownKeys , Shape > &
53+ objectUtil . flatten < objectUtil . addQuestionMarks < baseObjectOutputType < Shape > > >
5354
5455export type baseObjectOutputType < Shape extends ZodRawShape > = {
5556 [ k in keyof Shape ] : Shape [ k ] [ '_output' ]
@@ -58,19 +59,20 @@ export type baseObjectOutputType<Shape extends ZodRawShape> = {
5859export type objectInputType <
5960 Shape extends ZodRawShape ,
6061 UnknownKeys extends UnknownKeysParam = UnknownKeysParam ,
61- > = objectUtil . flatten < baseObjectInputType < Shape > > & UnknownKeysInputType < UnknownKeys >
62+ > = objectUtil . flatten < baseObjectInputType < Shape > > & UnknownKeysInputType < UnknownKeys , Shape >
63+
6264export type baseObjectInputType < Shape extends ZodRawShape > = objectUtil . addQuestionMarks < {
6365 [ k in keyof Shape ] : Shape [ k ] [ '_input' ]
6466} >
6567
66- export type UnknownKeysInputType < T extends UnknownKeysParam > = T extends ZodTypeAny
67- ? { [ k : string ] : T [ '_input' ] }
68+ export type UnknownKeysInputType < T extends UnknownKeysParam , S extends ZodRawShape > = T extends ZodTypeAny
69+ ? { [ k : string ] : T [ '_input' ] | ValueOf < baseObjectInputType < S > > } // extra properties cannot contradict the main properties
6870 : T extends 'passthrough'
6971 ? { [ k : string ] : unknown }
7072 : { }
7173
72- export type UnknownKeysOutputType < T extends UnknownKeysParam > = T extends ZodTypeAny
73- ? { [ k : string ] : T [ '_output' ] }
74+ export type UnknownKeysOutputType < T extends UnknownKeysParam , S extends ZodRawShape > = T extends ZodTypeAny
75+ ? { [ k : string ] : T [ '_output' ] | ValueOf < baseObjectOutputType < S > > } // extra properties cannot contradict the main properties
7476 : T extends 'passthrough'
7577 ? { [ k : string ] : unknown }
7678 : { }
0 commit comments