Skip to content

Commit

Permalink
feat(Object): Add OnlyRequired
Browse files Browse the repository at this point in the history
  • Loading branch information
SirWrexes committed Jun 4, 2023
1 parent e9de506 commit 98bf3d2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions types/ObjectUtils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export namespace Object {
>
: never

// prettier-ignore
type __OnlyRequired<T>
= T extends object
? { [K in keyof T as {} extends Pick<T, K> ? never : K]: __OnlyRequired<T[K]> }
: T

export type OnlyRequired<T extends object> = __OnlyRequired<T>

/** Build {@link PartialRecord}-like object that requires at least one field to be filled */
type SemiPartial<T extends object> = Values<{
[key in Keys<T>]: PartialExcept<Required<T>, key>
Expand Down

0 comments on commit 98bf3d2

Please sign in to comment.