Skip to content

Commit

Permalink
Update package/src/internal/types.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Luiz Ferraz <[email protected]>
  • Loading branch information
florian-lefebvre and Fryuni authored Feb 10, 2024
1 parent dc3cadb commit 2557059
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions package/src/internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ type PopUnion<U> = UnionToOvlds<U> extends (a: infer A) => void ? A : never;

type IsUnion<T> = [T] extends [UnionToIntersection<T>] ? false : true;

export type UnionToArray<
T,
A extends Array<unknown> = [],
> = IsUnion<T> extends true
? UnionToArray<Exclude<T, PopUnion<T>>, [PopUnion<T>, ...A]>
: [T, ...A];
export type UnionToArray<T> = IsUnion<T> extends true
? [...UnionToArray<Exclude<T, PopUnion<T>>>, PopUnion<T>]
: [T];

// Source: https://www.totaltypescript.com/concepts/the-prettify-helper
export type Prettify<T> = {
Expand Down

0 comments on commit 2557059

Please sign in to comment.