type-plus
    Preparing search index...

    Type Alias Options

    Options for selection (if-then-else) logic.

    The word "selection" refers to the basic elements in structural programming: sequence, selection, and iteration.

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

    namespace YourType {
    export type $Options = $SelectionOptions
    export type $Branch = $SelectionBranch
    }
    type Options = {
        $else?: unknown;
        $then?: unknown;
        selection?: "predicate" | "filter";
    }

    Hierarchy (View Summary)

    Index

    Properties

    $else?: unknown
    $then?: unknown
    selection?: "predicate" | "filter"

    Specifies which default selection logic to use.

    filter returns T when the condition is met, and returns never otherwise.

    predicate returns boolean depends on the condition.

    Note that setting $then and $else overrides the default selection logic.