devtypes - v2.0.0
    Preparing search index...

    Type Alias IsTypeExtendedInList<T, L>

    IsTypeExtendedInList: L extends [infer F, ...(infer R)]
        ? [F] extends [T] ? true : IsTypeExtendedInList<T, R>
        : false

    Test whether a type is being extended by a member of a list of types.

    Type Parameters

    • T

      A type to match against L

    • L extends any[]

      A list of types

    Iterate over the list L and tries each elements against T. This will return true if one type from L extends T. This will return false if nothing from L extended T.

    type A = IsTypeExtendedInList< 1 | true, [ false ] >; // false type B = IsTypeExtendedInList< 1 | boolean, [ false ] >; // true type C = IsTypeExtendedInList< 1 | false, [ false ] >; // true type D = IsTypeExtendedInList< 1 | false, [ boolean ] >; // false