Type Alias $ResolveBranch<$O, $Branches, D>

$ResolveBranch: $Branches extends [infer B]
    ? _Last<$O, B, D>
    : $Branches extends [
        infer B,
        ...(infer Rest extends ($Branch<any> | unknown)[]),
    ]
        ? _<$O, B, $ResolveBranch<$O, Rest, D>>
        : $InferError<"$Branches must have at least one entry">

Resolve option value based on list of branches. It returns the first branch value that is specified in the option, otherwise will return the default value.

Since this is an type utility, it does not perform extensive validations. Please check the description of each input below for information.

Type Parameters

  • $O extends Record<string, any>
  • $Branches extends ($Branch<any> | unknown)[]
  • D = unknown

$O The input option. It should be a Record, not any, unknown, or never

$B Tuple of branches with at least one entry.

D Default value to return if no branch is found.