Type alias IsUnion<Target>

IsUnion<Target>: [Target] extends [UnionToIntersection<Target>]
    ? false
    : true

IsUnion

Type Parameters

  • Target

    The type to check

Desc

Check if Target is a union

Returns

A boolean

Example

type Value = 'i.go.to.school.by.bus';
type IsUnionValue = IsUnion<Value>; // false

Example

type Union = { a: string } | { b: number };
type IsUnionUnion = IsUnion<Union>; // true

Example

type Intersection = { a: string } & { b: number };
type IsUnionIntersection = IsUnion<Intersection>; // false