devtypes - v2.0.0
    Preparing search index...

    Type Alias IfExactly<T, N, Then, Else>

    IfExactly: IfEquals<CountTrue<T>, N, Then, Else>

    Conditional helper: exactly N true values.

    Type Parameters

    • T extends readonly boolean[]

      Tuple of boolean conditions

    • N extends number

      Exact number of true values required

    • Then

      Result if the condition matches

    • Else = never

      Result otherwise

    Resolves to Then if the tuple contains exactly N occurrences of true, otherwise Else.

    type A = IfExactly< [ true, false, true ], 2, 'yes', 'no' >;  // 'yes'
    type B = IfExactly< [ true, true ], 1, 'yes', 'no' >; // 'no'