File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ describe('$AnyFunction', () => {
239239} ) ;
240240
241241describe ( '$$Function' , ( ) => {
242- const $Schema = $$Function ( { input : z4 . tuple ( [ z4 . number ( ) , z4 . number ( ) ] ) , output : z4 . number ( ) } ) ;
242+ const $Schema = $$Function ( { input : [ z4 . number ( ) , z4 . number ( ) ] , output : z4 . number ( ) } ) ;
243243 it ( 'should be correctly typed' , ( ) => {
244244 expectTypeOf < z4 . infer < typeof $Schema > > ( ) . toEqualTypeOf < ( arg_0 : number , arg_1 : number ) => number > ( ) ;
245245 } ) ;
Original file line number Diff line number Diff line change @@ -121,18 +121,24 @@ export const $Uint8ArrayLike: z4.ZodType<Uint8Array> = z4
121121
122122export const $AnyFunction = z4 . custom < ( ...args : any [ ] ) => any > ( ( arg ) => typeof arg === 'function' , 'must be function' ) ;
123123
124- export const $$Function = < TInput extends z4 . ZodType < unknown [ ] , unknown [ ] > , TOutput extends z4 . ZodType > ( params ?: {
124+ export const $$Function = < TInput extends [ z4 . ZodType , ...z4 . ZodType [ ] ] , TOutput extends z4 . ZodType > ( {
125+ input,
126+ output
127+ } : {
125128 input : TInput ;
126129 output : TOutput ;
127- } ) : z4 . ZodType < ( ...args : z4 . output < TInput > ) => z4 . output < TOutput > > => {
128- const $Schema = z4 . function ( params ) ;
130+ } ) : z4 . ZodType < ( ...args : z4 . output < z4 . ZodTuple < TInput , null > > ) => z4 . output < TOutput > > => {
131+ const $Schema = z4 . function ( {
132+ input : z4 . tuple ( input ) ,
133+ output
134+ } ) ;
129135 return z4 . custom ( ) . transform ( ( arg , ctx ) => {
130136 if ( typeof arg !== 'function' ) {
131137 ctx . addIssue ( 'Must be function' ) ;
132138 return z4 . NEVER ;
133139 }
134140 return $Schema . implement ( arg as ( ...args : any [ ] ) => any ) ;
135- } ) as z4 . ZodType < ( ...args : z4 . output < TInput > ) => z4 . output < TOutput > > ;
141+ } ) as z4 . ZodType < ( ...args : z4 . output < z4 . ZodTuple < TInput , null > > ) => z4 . output < TOutput > > ;
136142} ;
137143
138144export function safeParse < TSchema extends z4 . ZodTypeAny > (
You can’t perform that action at this time.
0 commit comments