Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak RecursivePartial to accept null #600

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,10 @@ export interface InternalHooks {
}

/** Only return partial when type is not any */
type RecursivePartial<T> =
NonNullable<T> extends object
? {
[P in keyof T]?: NonNullable<T[P]> extends (infer U)[]
? RecursivePartial<U>[]
: NonNullable<T[P]> extends object
? RecursivePartial<T[P]>
: T[P];
}
: T;

export type FilterFunc = (meta: Meta | null) => boolean;

export type GetFieldsValueConfig = { strict?: boolean; filter?: FilterFunc };
type NoUndefined<T> = Exclude<T, undefined>;
type RecursivePartial<T> = NoUndefined<T> extends object ? {
[P in keyof T]?: NoUndefined<T[P]> extends (infer U)[] ? RecursivePartial<U>[] : NoUndefined<T[P]> extends object ? RecursivePartial<T[P]> : T[P];
} : T;

export interface FormInstance<Values = any> {
// Origin Form API
Expand Down