devtypes - v2.0.0
    Preparing search index...

    Type Alias IsUnion<T, U>

    IsUnion: IsNever<T> extends true
        ? false
        : T extends any ? [U] extends [T] ? false : true : false

    Type guard: detect whether a type is a union.

    Type Parameters

    • T

      Type to test

    • U = T

    Resolves to true if T is a union type, otherwise false.

    type A = IsUnion< string | number >;  // true
    type B = IsUnion< string >; // false