Type Alias FindLast<A, Criteria>
FindLast<A, Criteria>: IsTuple<A, { $else: A extends Readonly<(infer T)[]> ? T extends Criteria ? T | undefined : never : never; $then: A["length"] extends 0 ? never : A extends readonly [...(infer Heads), infer Last] ? Last extends Criteria ? Last : FindLast<Heads, Criteria> : never; }> Type Parameters
- A extends readonly unknown[]
- Criteria
🦴 utilities
Gets the last type in the array or tuple that matches the
Criteria
.If the
Criteria
is not met, it will return `never'.For
Array<T>
, it will returnT | undefined
ifT
satisfiesCriteria
.