Skip to content

Commit ee201e4

Browse files
committed
🔧 fix: merge multiple nested guard with schema
1 parent d3424c1 commit ee201e4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,12 @@ export const mergeHook = (
251251
// customBStore[union]
252252
// )
253253

254-
if (!Object.values(b).find((x) => x !== undefined && x !== null))
255-
return { ...a } as any
256-
257254
if (!b) return (a as any) ?? {}
258255
if (!a) return b ?? {}
259256

257+
if (!Object.values(b).find((x) => x !== undefined && x !== null))
258+
return { ...a } as any
259+
260260
const hook = {
261261
...a,
262262
...b,
@@ -1213,6 +1213,7 @@ export function deepClone<T>(source: T, weak = new WeakMap<object, any>()): T {
12131213

12141214
const cloned: Partial<T> = {}
12151215

1216+
weak.set(source as object, cloned)
12161217
for (const key of keys)
12171218
cloned[key as keyof T] = deepClone((source as any)[key], weak)
12181219

0 commit comments

Comments
 (0)