Type Alias Branch<$O>

Branch: { $else: $Else; $then: $Then } & $O

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 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