🧰 type util

$Never.$Options enables customizing the behavior of the $never branch.

The $never branch is used to handle when the input type is never.

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

namespace YourType {
export type $Options = $Never.$Options
export type $Branch = $Never.$Branch
}
interface Options {
    $else?: unknown;
    $never?: unknown;
    $notArray?: unknown;
    $then?: unknown;
    selection?: "predicate" | "filter";
}

Hierarchy (view full)

Properties

$else?: unknown
$never?: unknown
$notArray?: 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.