@@ -44,27 +44,27 @@ export class ZodSchemaVisitor extends BaseSchemaVisitor {
4444 initialEmit ( ) : string {
4545 return (
4646 `\n${
47- [
48- new DeclarationBlock ( { } )
49- . asKind ( 'type' )
50- . withName ( 'Properties<T>' )
51- . withContent ( [ 'Required<{' , ' [K in keyof T]: z.ZodType<T[K], any, T[K]>;' , '}>' ] . join ( '\n' ) ) . string ,
52- // Unfortunately, zod doesn’t provide non-null defined any schema.
53- // This is a temporary hack until it is fixed.
54- // see: https://github.com/colinhacks/zod/issues/884
55- new DeclarationBlock ( { } ) . asKind ( 'type' ) . withName ( 'definedNonNullAny' ) . withContent ( '{}' ) . string ,
56- new DeclarationBlock ( { } )
57- . export ( )
58- . asKind ( 'const' )
59- . withName ( `isDefinedNonNullAny` )
60- . withContent ( `(v: any): v is definedNonNullAny => v !== undefined && v !== null` ) . string ,
61- new DeclarationBlock ( { } )
62- . export ( )
63- . asKind ( 'const' )
64- . withName ( `${ anySchema } ` )
65- . withContent ( `z.any().refine((v) => isDefinedNonNullAny(v))` ) . string ,
66- ...this . enumDeclarations ,
67- ] . join ( '\n' ) } `
47+ [
48+ new DeclarationBlock ( { } )
49+ . asKind ( 'type' )
50+ . withName ( 'Properties<T>' )
51+ . withContent ( [ 'Required<{' , ' [K in keyof T]: z.ZodType<T[K], any, T[K]>;' , '}>' ] . join ( '\n' ) ) . string ,
52+ // Unfortunately, zod doesn’t provide non-null defined any schema.
53+ // This is a temporary hack until it is fixed.
54+ // see: https://github.com/colinhacks/zod/issues/884
55+ new DeclarationBlock ( { } ) . asKind ( 'type' ) . withName ( 'definedNonNullAny' ) . withContent ( '{}' ) . string ,
56+ new DeclarationBlock ( { } )
57+ . export ( )
58+ . asKind ( 'const' )
59+ . withName ( `isDefinedNonNullAny` )
60+ . withContent ( `(v: any): v is definedNonNullAny => v !== undefined && v !== null` ) . string ,
61+ new DeclarationBlock ( { } )
62+ . export ( )
63+ . asKind ( 'const' )
64+ . withName ( `${ anySchema } ` )
65+ . withContent ( `z.any().refine((v) => isDefinedNonNullAny(v))` ) . string ,
66+ ...this . enumDeclarations ,
67+ ] . join ( '\n' ) } `
6868 ) ;
6969 }
7070
0 commit comments