From 4dca5e0f7adb876ef0aa8bc7378a5bdca1affdcd Mon Sep 17 00:00:00 2001 From: Danil Tarasov Date: Sat, 14 Jan 2023 10:20:47 +0300 Subject: [PATCH] fix(types): fix toUnion signature to correctly infer type --- src/types.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index e366f97..d60d5ec 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,7 +54,9 @@ export type ToTuple = T extends [Parser, ...infer Tail] * type R = ToUnion // type R = string | number | boolean * ``` */ -export type ToUnion = T extends [Parser, ...infer Tail] +export type ToUnion = T extends Array> + ? Inner + : T extends [Parser, ...infer Tail] ? Head | ToUnion : never