Skip to content

Commit

Permalink
chore: organize types layout
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGw committed Apr 26, 2024
1 parent 2891b4d commit 7332b2a
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,25 @@ export type IsDeepMutable<T> = T extends DeepMutable<T> ? true : false;
*/
export type IsDeepImmutable<T> = T extends DeepImmutable<T> ? true : false;

/**
* Check if all the properties of a given object (nested) are required
* @returns
* `true` if all the properties are, otherwise `false`
*/
export type IsDeepRequired<T> = IfExtends<T, DeepRequired<T>, true, false>;

/**
* Check if all the properties of a given object (nested) are non required
* @returns
* `true` if all the properties are, otherwise `false`
*/
export type IsDeepNonRequired<T> = IfExtends<
T,
DeepNonRequired<T>,
true,
false
>;

/**
* A type that recursively turns the proprties within a given object type `T` immutable.
* @example
Expand Down Expand Up @@ -1618,16 +1637,9 @@ export type DeepRequired<T> = T extends UnknownFunction
[K in Keys<T>]-?: IfExtends<T[K], unknown, DeepRequired<T[K]>, T[K]>;
};

/**
* Check if all the properties of a given object (nested) are required
* @returns
* `true` if all the properties are, otherwise `false`
*/
export type IsDeepRequired<T> = IfExtends<T, DeepRequired<T>, true, false>;

/**
* Why not call it ``DeepOptional``?
* ``Optional<T>`` in this library represents a type ``T`` that can be either ``T`` or ``null``. So creating
* ``Optional<T>`` in this library `Optional` represents a type ``T`` that can be either ``T`` or ``null``. So creating
* ``DeepOptional`` type would entail adding null to every property, which is not the intention here.
*
* ``DeepNonRequired<T>`` turns all required keys in a given object (nested) to non required one.
Expand Down Expand Up @@ -1676,18 +1688,6 @@ export type DeepNonRequired<T> = T extends UnknownFunction
[K in Keys<T>]+?: IfExtends<T[K], unknown, DeepNonRequired<T[K]>, T[K]>;
};

/**
* Check if all the properties of a given object (nested) are non required
* @returns
* `true` if all the properties are, otherwise `false`
*/
export type IsDeepNonRequired<T> = IfExtends<
T,
DeepNonRequired<T>,
true,
false
>;

/**
* @hidden
*/
Expand Down

0 comments on commit 7332b2a

Please sign in to comment.