1
1
import { expect , expectTypeOf , test } from "vitest" ;
2
2
import { z } from "zod/v4" ;
3
- import type { util } from "zod/v4/core" ;
4
3
5
4
test ( "basic catch" , ( ) => {
6
5
expect ( z . string ( ) . catch ( "default" ) . parse ( undefined ) ) . toBe ( "default" ) ;
@@ -45,7 +44,7 @@ test("catch with transform", () => {
45
44
expect ( stringWithDefault . unwrap ( ) . out ) . toBeInstanceOf ( z . ZodTransform ) ;
46
45
47
46
type inp = z . input < typeof stringWithDefault > ;
48
- expectTypeOf < inp > ( ) . toEqualTypeOf < string | util . Whatever > ( ) ;
47
+ expectTypeOf < inp > ( ) . toEqualTypeOf < string > ( ) ;
49
48
type out = z . output < typeof stringWithDefault > ;
50
49
expectTypeOf < out > ( ) . toEqualTypeOf < string > ( ) ;
51
50
} ) ;
@@ -59,7 +58,7 @@ test("catch on existing optional", () => {
59
58
expect ( stringWithDefault . unwrap ( ) . unwrap ( ) ) . toBeInstanceOf ( z . ZodString ) ;
60
59
61
60
type inp = z . input < typeof stringWithDefault > ;
62
- expectTypeOf < inp > ( ) . toEqualTypeOf < string | undefined | util . Whatever > ( ) ;
61
+ expectTypeOf < inp > ( ) . toEqualTypeOf < string | undefined > ( ) ;
63
62
type out = z . output < typeof stringWithDefault > ;
64
63
expectTypeOf < out > ( ) . toEqualTypeOf < string | undefined > ( ) ;
65
64
} ) ;
@@ -68,7 +67,7 @@ test("optional on catch", () => {
68
67
const stringWithDefault = z . string ( ) . catch ( "asdf" ) . optional ( ) ;
69
68
70
69
type inp = z . input < typeof stringWithDefault > ;
71
- expectTypeOf < inp > ( ) . toEqualTypeOf < string | util . Whatever > ( ) ;
70
+ expectTypeOf < inp > ( ) . toEqualTypeOf < string | undefined > ( ) ;
72
71
type out = z . output < typeof stringWithDefault > ;
73
72
expectTypeOf < out > ( ) . toEqualTypeOf < string | undefined > ( ) ;
74
73
} ) ;
@@ -102,7 +101,7 @@ test("nested", () => {
102
101
inner : "asdf" ,
103
102
} ) ;
104
103
type input = z . input < typeof outer > ;
105
- expectTypeOf < input > ( ) . toEqualTypeOf < { inner : string | util . Whatever } | util . Whatever > ( ) ;
104
+ expectTypeOf < input > ( ) . toEqualTypeOf < { inner : string } > ( ) ;
106
105
type out = z . output < typeof outer > ;
107
106
108
107
expectTypeOf < out > ( ) . toEqualTypeOf < { inner : string } > ( ) ;
0 commit comments