@@ -42,7 +42,6 @@ export interface SetAtom<T> extends ZodAtom<[T]>, ReatomSetAtom<T> {}
42
42
export interface LinkedListAtom < Params extends any [ ] = any [ ] , Model extends Rec = Rec > extends ZodAtom < Array < Model > > , ReatomLinkedListAtom < Params , Model > { }
43
43
44
44
type DistributeIntersection < U , T > = U extends any ? U & T : never ;
45
- type Example = DistributeIntersection < number | string | boolean , z . BRAND < 'test' > > ;
46
45
47
46
export type ZodAtomization < T extends z . ZodFirstPartySchemaTypes , Union = never , Intersection = unknown > = T extends z . ZodAny
48
47
? AtomMut < ( any & Intersection ) | Union >
@@ -63,11 +62,11 @@ export type ZodAtomization<T extends z.ZodFirstPartySchemaTypes, Union = never,
63
62
: T extends z . ZodLiteral < infer T >
64
63
? ( T & Intersection ) | Union
65
64
: T extends z . ZodBoolean
66
- ? never extends Union
65
+ ? [ Union ] extends [ never ]
67
66
? BooleanAtom
68
67
: AtomMut < ( boolean & Intersection ) | Union >
69
68
: T extends z . ZodNumber
70
- ? never extends Union
69
+ ? [ Union ] extends [ never ]
71
70
? NumberAtom
72
71
: AtomMut < ( number & Intersection ) | Union >
73
72
: T extends z . ZodBigInt
@@ -83,29 +82,31 @@ export type ZodAtomization<T extends z.ZodFirstPartySchemaTypes, Union = never,
83
82
: T extends z . ZodTuple < infer Tuple >
84
83
? AtomMut < ( z . infer < Tuple [ number ] > & Intersection ) | Union >
85
84
: T extends z . ZodObject < infer Shape >
86
- ? never extends Union
85
+ ? [ Union ] extends [ never ]
87
86
? {
88
87
[ K in keyof Shape ] : ZodAtomization < Shape [ K ] > ;
89
88
} & Intersection
90
- : AtomMut < ( Shape & Intersection ) | Union >
89
+ : AtomMut < ( {
90
+ [ K in keyof Shape ] : ZodAtomization < Shape [ K ] >
91
+ } & Intersection ) | Union >
91
92
: T extends z . ZodRecord < infer KeyType , infer ValueType >
92
- ? never extends Union
93
+ ? [ Union ] extends [ never ]
93
94
? RecordAtom < Record < z . infer < KeyType > , ZodAtomization < ValueType > > >
94
95
: AtomMut < ( Record < z . infer < KeyType > , ZodAtomization < ValueType > > & Intersection ) | Union >
95
96
: T extends z . ZodMap < infer KeyType , infer ValueType >
96
- ? never extends Union
97
+ ? [ Union ] extends [ never ]
97
98
? MapAtom < z . infer < KeyType > , ZodAtomization < ValueType > >
98
99
: AtomMut < ( Map < z . infer < KeyType > , ZodAtomization < ValueType > > & Intersection ) | Union >
99
100
: T extends z . ZodSet < infer ValueType >
100
- ? never extends Union
101
+ ? [ Union ] extends [ never ]
101
102
? SetAtom < z . infer < ValueType > >
102
103
: AtomMut < ( Set < z . infer < ValueType > > & Intersection ) | Union >
103
104
: T extends z . ZodEnum < infer Enum >
104
- ? never extends Union
105
+ ? [ Union ] extends [ never ]
105
106
? EnumAtom < Enum [ number ] >
106
107
: AtomMut < ( Enum [ number ] & Intersection ) | Union >
107
108
: T extends z . ZodNativeEnum < infer Enum >
108
- ? never extends Union
109
+ ? [ Union ] extends [ never ]
109
110
? // @ts -expect-error шо?
110
111
EnumAtom < Enum [ keyof Enum ] >
111
112
: AtomMut < ( Enum [ keyof Enum ] & Intersection ) | Union >
@@ -128,7 +129,7 @@ export type ZodAtomization<T extends z.ZodFirstPartySchemaTypes, Union = never,
128
129
: T extends z . ZodUnion < infer T >
129
130
? AtomMut < DistributeIntersection < z . infer < T [ number ] > , Intersection > | Union >
130
131
: T extends z . ZodDiscriminatedUnion < infer K , infer T >
131
- ? never extends Union
132
+ ? [ Union ] extends [ never ]
132
133
? T extends Array < z . ZodObject < infer Shape > >
133
134
? Atom < {
134
135
[ K in keyof Shape ] : ZodAtomization < Shape [ K ] > ;
0 commit comments