1
- import { unique } from '../../utils'
1
+ import { unique , ValueOf } from '../../utils'
2
2
import {
3
3
ZodArray ,
4
4
ZodEnum ,
@@ -49,7 +49,8 @@ export type mergeTypes<A, B> = {
49
49
export type objectOutputType <
50
50
Shape extends ZodRawShape ,
51
51
UnknownKeys extends UnknownKeysParam = UnknownKeysParam ,
52
- > = objectUtil . flatten < objectUtil . addQuestionMarks < baseObjectOutputType < Shape > > > & UnknownKeysOutputType < UnknownKeys >
52
+ > = UnknownKeysOutputType < UnknownKeys , Shape > &
53
+ objectUtil . flatten < objectUtil . addQuestionMarks < baseObjectOutputType < Shape > > >
53
54
54
55
export type baseObjectOutputType < Shape extends ZodRawShape > = {
55
56
[ k in keyof Shape ] : Shape [ k ] [ '_output' ]
@@ -58,19 +59,20 @@ export type baseObjectOutputType<Shape extends ZodRawShape> = {
58
59
export type objectInputType <
59
60
Shape extends ZodRawShape ,
60
61
UnknownKeys extends UnknownKeysParam = UnknownKeysParam ,
61
- > = objectUtil . flatten < baseObjectInputType < Shape > > & UnknownKeysInputType < UnknownKeys >
62
+ > = objectUtil . flatten < baseObjectInputType < Shape > > & UnknownKeysInputType < UnknownKeys , Shape >
63
+
62
64
export type baseObjectInputType < Shape extends ZodRawShape > = objectUtil . addQuestionMarks < {
63
65
[ k in keyof Shape ] : Shape [ k ] [ '_input' ]
64
66
} >
65
67
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
68
70
: T extends 'passthrough'
69
71
? { [ k : string ] : unknown }
70
72
: { }
71
73
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
74
76
: T extends 'passthrough'
75
77
? { [ k : string ] : unknown }
76
78
: { }
0 commit comments