Skip to content

Commit

Permalink
fix(types): fix toUnion signature to correctly infer type
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFedaikin authored and norskeld committed Jan 14, 2023
1 parent b1f48f1 commit 4dca5e0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export type ToTuple<T> = T extends [Parser<infer Head>, ...infer Tail]
* type R = ToUnion<U> // type R = string | number | boolean
* ```
*/
export type ToUnion<T> = T extends [Parser<infer Head>, ...infer Tail]
export type ToUnion<T> = T extends Array<Parser<infer Inner>>
? Inner
: T extends [Parser<infer Head>, ...infer Tail]
? Head | ToUnion<Tail>
: never

Expand Down

1 comment on commit 4dca5e0

@vercel
Copy link

@vercel vercel bot commented on 4dca5e0 Jan 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.