declare namespace Util { /** convert a union to an intersection: X | Y | Z ==> X & Y & Z */ type UnionToIntersection = (T extends any ? (args: T) => any : never) extends (args: infer R) => any ? R : never; /** returns true if the type is a union otherwise false */ type IsUnion = [T] extends [UnionToIntersection] ? false : true; type LastInUnion = UnionToIntersection any : never> extends (arg: infer R) => any ? R : never; type UnionToTuple = [T] extends [never] ? [] : [LastInUnion, ...UnionToTuple>>]; type Inter = UnionToTuple<'1' | '2'>; }