Convert a union type to an intersection type using distributive conditional types.
Inspired by this Stack Overflow answer.
import type {UnionToIntersection} from 'type-fest';type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};type Intersection = UnionToIntersection<Union>;//=> {the(): void} & {great(arg: string): void} & {escape: boolean} Copy
import type {UnionToIntersection} from 'type-fest';type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};type Intersection = UnionToIntersection<Union>;//=> {the(): void} & {great(arg: string): void} & {escape: boolean}
Convert a union type to an intersection type using distributive conditional types.
Inspired by this Stack Overflow answer.