Type Alias IsBoolean<T, $O>

IsBoolean<T, $O>: $SpecialType<T, $MergeOptions<$O, {
    $else: IsBoolean.$<T, $O>;
    $then: $ResolveBranch<T, $O, [$Else]>;
}>>

🎭 predicate

Validate if T is boolean, including true and false.

Type Parameters

type R = IsBoolean<boolean> // true
type R = IsBoolean<true> // true
type R = IsBoolean<false> // true

type R = IsBoolean<number> // false
type R = IsBoolean<unknown> // false
type R = IsBoolean<string | boolean> // boolean

🔢 customize

Filter to ensure T is boolean, including true and false, otherwise returns never.

type R = IsBoolean<boolean, { selection: 'filter' }> // boolean
type R = IsBoolean<true, { selection: 'filter' }> // true
type R = IsBoolean<false, { selection: 'filter' }> // true

type R = IsBoolean<number, { selection: 'filter' }> // never
type R = IsBoolean<unknown, { selection: 'filter' }> // never
type R = IsBoolean<never, { selection: 'filter' }> // never
type R = IsBoolean<string | boolean, { selection: 'filter' }> // boolean

🔢 customize:

Disable distribution of union types.

type R = IsBoolean<boolean | 1> // boolean
type R = IsBoolean<boolean | 1, { distributive: false }> // false

🔢 customize

Use unique branch identifiers to allow precise processing of the result.

type R = IsBoolean<boolean, $SelectionBranch> // $Then
type R = IsBoolean<string, $SelectionBranch> // $Else