devtypes - v2.0.0
    Preparing search index...

    Type Alias UnionHas<U, T>

    UnionHas: [T] extends [U] ? true : false

    Check if a union type includes a specific type.

    Type Parameters

    • U

      A union type

    • T

      The type to check for membership in the union

    Evaluates to true if the type T is assignable to the union U, otherwise evaluates to false.

    type U = string | number | boolean;
    type HasString = UnionHas< U, string >; // true
    type HasDate = UnionHas< U, Date >; // false