devtypes - v2.0.0
    Preparing search index...

    Type Alias IsTypeInList<T, L>

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

    Test whether a type can be found within a list of types.

    Type Parameters

    • T

      A type to search for

    • L extends any[]

      A list of types

    This will recursively check each type in the list L to see if it matches type T. If returns true as soon as a match is found and false if no matches are found or if the list is empty.

    type TrueIsFound = IsTypeInList< true, [ 1, 'no', true ] >;      // true
    type TrueIsNotFound = IsTypeInList< true, [ 1, 'no', false ] >; // false
    type ListIsEmptySoFalse = IsTypeInList< true, [] >; // false