Skip to content

Commit 83b0852

Browse files
authored
Tweak RecursivePartial to accept null
1 parent 18c4e0b commit 83b0852

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/interface.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,14 @@ export interface InternalHooks {
231231
getInitialValue: (namePath: InternalNamePath) => StoreValue;
232232
}
233233

234+
type NoUndefined<T> = Exclude<T, undefined>;
235+
234236
/** Only return partial when type is not any */
235-
type RecursivePartial<T> = NonNullable<T> extends object
237+
type RecursivePartial<T> = NoUndefined<T> extends object
236238
? {
237-
[P in keyof T]?: NonNullable<T[P]> extends (infer U)[]
239+
[P in keyof T]?: NoUndefined<T[P]> extends (infer U)[]
238240
? RecursivePartial<U>[]
239-
: NonNullable<T[P]> extends object
241+
: NoUndefined<T[P]> extends object
240242
? RecursivePartial<T[P]>
241243
: T[P];
242244
}

0 commit comments

Comments
 (0)