typeR = FindFirst<[true, 1, 'x'], 2> // never typeR = FindFirst<string[], number> // never
@typeParam Options['widen'] performs widen match.
Default to true.
With widen match, a narrowed type will match its widen type.
e.g. matching 1 against number yields 1 | undefined
The widen behavior can be customized by Options['$widen']
@typeParam Options['caseEmptyTuple'] return type when A is an empty tuple.
Default to never.
@typeParam Options['$never'] return type when A is never. Default to never.
@typeParam Options['$noMatch'] Return value when T does not match Criteria.
Default to never.
@typeParam Options['$widen'] return type when T in A is a widen type of Criteria.
Default to Criteria | undefined.
Set it to never for a more type-centric behavior
@typeParam Options['$unionMiss'] Return value when a branch of the union T does not match Criteria.
Default to undefined.
Since it is a union, the result will be join to the matched branch as union.
🦴 utilities 🔢 customizable
Find the first type in the array or tuple
A
that matchesCriteria
.If the
Criteria
is not met, it will return `never'.@example
@typeParam Options['widen'] performs widen match. Default to
true
. With widen match, a narrowed type will match its widen type. e.g. matching1
againstnumber
yields1 | undefined
The widen behavior can be customized by
Options['$widen']
@typeParam Options['caseEmptyTuple'] return type when
A
is an empty tuple. Default tonever
.@typeParam Options['$never'] return type when
A
isnever
. Default tonever
.@typeParam Options['$noMatch'] Return value when
T
does not matchCriteria
. Default tonever
.@typeParam Options['$widen'] return type when
T
inA
is a widen type ofCriteria
. Default toCriteria | undefined
. Set it tonever
for a more type-centric behavior@typeParam Options['$unionMiss'] Return value when a branch of the union
T
does not matchCriteria
. Default toundefined
. Since it is a union, the result will be join to the matched branch as union.