Type alias $SelectionBranch<$O>

$SelectionBranch<$O>: {
    $else: $Else;
    $then: $Then;
} & $O

🧰 type util

Branch option for selection logic. It allows finely customizing the behavior of your type.

Using this as the default value of your $Options is the recommended best practice.

This encourage consumer of your type to use conditional type to avoid performance issues.

Type Parameters

Type declaration

Example

type YourType<
T,
$Options extends YourType.$Options = YourType.$Branch
> = ...

namespace YourType {
export type $Options = $SelectionOptions
export type $Branch = $SelectionBranch
}

type R = YourType<T> extends infer R
? R extends $Then ? HandleThen
: R extends $Else ? HandleElse
: never

Generated using TypeDoc