Skip to content

Commit

Permalink
chore: add IsNever
Browse files Browse the repository at this point in the history
  • Loading branch information
Raiden1411 committed May 21, 2023
1 parent 5502867 commit 350f957
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ type _TupleOf<
export type IsEmptyObject<
T extends object,
AllKeys extends keyof T = keyof T,
> = [AllKeys] extends [never] ? true : false
> = IsNever<AllKeys>

/**
* Flattens array of nested arrays into a single array with all of the elements.
Expand Down Expand Up @@ -235,3 +235,12 @@ export type IsArrayString<T extends string> =
export type Pop<T extends readonly number[]> = T extends [...infer R, any]
? R
: []

/**
* Checks if {@link T} is `never`
* @param T - Type to check
* @example
* type Result = IsNever<never>
* // ^? type Result = true
*/
export type IsNever<T> = [T] extends [never] ? true : false

0 comments on commit 350f957

Please sign in to comment.