Type Alias $Select<T, U, $O>

$Select<T, U, $O>: $SpecialType<T, {
    $any: $ResolveBranch<T, $O, [$Any, $Else]>;
    $else: $ResolveBranch<T, $O, [$Else], $Select._<T, U, $O>>;
    $never: $ResolveBranch<T, $O, [$Never, $Else]>;
    $unknown: $ResolveBranch<T, $O, [$Unknown, $Else]>;
}>

🎭 predicate ㊙️ internal

Validate if T is U.

Type Parameters

type R = $Select<undefined, undefined> // true

type R = $Select<never, undefined> // false
type R = $Select<unknown, undefined> // false
type R = $Select<string | boolean, undefined> // false

type R = $Select<string | undefined, undefined> // boolean

🔢 customize

Filter to ensure T is U, otherwise returns never.

type R = $Select<undefined, undefined, { selection: 'filter' }> // undefined

type R = $Select<never, undefined, { selection: 'filter' }> // never
type R = $Select<unknown, undefined, { selection: 'filter' }> // never
type R = $Select<string | boolean, undefined, { selection: 'filter' }> // never

type R = $Select<string | undefined, undefined> // undefined

🔢 customize:

Disable distribution of union types.

type R = $Select<undefined | 1, undefined> // boolean
type R = $Select<undefined | 1, undefined, { distributive: false }> // false

🔢 customize

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

type R = $Select<undefined, undefined, $SelectionBranch> // $Then
type R = $Select<string, undefined, $SelectionBranch> // $Else