@@ -23,7 +23,10 @@ declare module "@zod/core" {
2323
2424declare module "zod" {
2525 interface ZodType {
26- /** @desc Add an example value (before any transformations, can be called multiple times) */
26+ /**
27+ * @todo this should be changed to z.output
28+ * @desc Add an example value (before any transformations, can be called multiple times)
29+ * */
2730 example ( example : z . input < this> ) : this;
2831 deprecated ( ) : this;
2932 }
@@ -55,12 +58,12 @@ declare module "zod" {
5558}
5659
5760const exampleSetter = function ( this : z . ZodType , value : z . input < typeof this > ) {
58- const { examples, ...rest } = this . meta ( ) ?. [ metaSymbol ] || { examples : [ ] } ;
61+ const { examples = [ ] , ...rest } = this . meta ( ) || { } ;
5962 const copy = examples . slice ( ) ;
6063 copy . push ( value ) ;
6164 return this . meta ( {
62- description : this . description ,
63- [ metaSymbol ] : { ...rest , examples : copy } ,
65+ examples : copy ,
66+ ...rest ,
6467 } ) ;
6568} ;
6669
@@ -78,7 +81,7 @@ const labelSetter = function (
7881) {
7982 return this . meta ( {
8083 description : this . description ,
81- [ metaSymbol ] : { examples : [ ] , ...this . meta ( ) ?. [ metaSymbol ] , defaultLabel } ,
84+ [ metaSymbol ] : { ...this . meta ( ) ?. [ metaSymbol ] , defaultLabel } ,
8285 } ) ;
8386} ;
8487
@@ -88,7 +91,7 @@ const brandSetter = function (
8891) {
8992 return this . meta ( {
9093 description : this . description ,
91- [ metaSymbol ] : { examples : [ ] , ...this . meta ( ) ?. [ metaSymbol ] , brand } ,
94+ [ metaSymbol ] : { ...this . meta ( ) ?. [ metaSymbol ] , brand } ,
9295 } ) ;
9396} ;
9497
@@ -147,9 +150,12 @@ if (!(metaSymbol in globalThis)) {
147150 ...args : Parameters < z . ZodType [ "check" ] >
148151 ) {
149152 /** @link https://v4.zod.dev/metadata#register */
150- return originalCheck . apply ( this , args ) . register ( globalRegistry , {
151- [ metaSymbol ] : this . meta ( ) ?. [ metaSymbol ] ,
152- } ) ;
153+ return (
154+ originalCheck
155+ . apply ( this , args )
156+ // @ts -expect-error -- ignore type because it's unknown
157+ . register ( globalRegistry , this . meta ( ) || { } )
158+ ) ;
153159 } ;
154160 } ,
155161 } ,
0 commit comments