Skip to content

Commit

Permalink
refactor(types): use DeepPartial in OrPartial union
Browse files Browse the repository at this point in the history
  • Loading branch information
unicornware committed May 24, 2021
1 parent 49f6f9a commit 8a3b158
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,29 +271,47 @@ export type OmitByType<T, P> = Pick<
*
* @template T - Data
*/
export type OneOrMany<T = ANY> = T | Array<T>
export type OneOrMany<T> = T | Array<T>

/**
* Represents data returned by a function, or the return type of a function that
* never returns a value because an error was thrown.
*
* @template T - Return value
*/
export type OrNever<T = any> = T | never
export type OrNever<T> = T | never

/**
* Type allowing all properties of T or some properties of T.
*
* @template T - Object type
* @template T - Value type
*/
export type OrPartial<T = UnknownObject> = T | Partial<T>
export type OrPartial<T> = T | DeepPartial<T>

/**
* Type representing an asynchronous or synchronous value.
*
* @template T - type
* @template T - Value type
*/
export type OrPromise<T> = T | Promise<T>

/**
* Omit certain fields while making others optional.
*
* @template T - Object type
* @template K - Object fields (top level) to omit
*/
export type OrPromise<T = any> = T | Promise<T>
export type PartialBy<T, K extends keyof T> = Omit<T, K> &
DeepPartial<Pick<T, K>>

/**
* Pick (require) certain fields while making others required.
*
* @template T - Object type
* @template K - Object fields (top level) to pick
*/
export type PartialByRequired<T, K extends keyof T> = Pick<T, K> &
DeepPartial<Omit<T, K>>

/**
* Type representing a nested or top level object key.
Expand Down Expand Up @@ -352,24 +370,6 @@ export type PathValue<
? T[P]
: never

/**
* Omit certain fields while making others optional.
*
* @template T - Object type
* @template K - Object fields (top level) to omit
*/
export type PartialBy<T, K extends keyof T> = Omit<T, K> &
DeepPartial<Pick<T, K>>

/**
* Pick (require) certain fields while making others required.
*
* @template T - Object type
* @template K - Object fields (top level) to pick
*/
export type PartialByRequired<T, K extends keyof T> = Pick<T, K> &
DeepPartial<Omit<T, K>>

/**
* Picks all properties of given type in object type.
*
Expand Down

0 comments on commit 8a3b158

Please sign in to comment.