A utility type that extracts the first N elements from a tuple type T. If the tuple T has fewer than N elements, it returns the entire tuple.
N
T
This type is implemented recursively:
R
The tuple type from which to extract the first N elements.
The number of elements to extract from the start of the tuple.
An accumulator for storing the extracted elements (used internally in the recursion). Defaults to an empty array [].
[]
// Extracts the first 2 elements from the tupletype Example = TakeFirstKeys<QueryListKey<'post'>, 2>;// Result: ['get-list', 'post'] Copy
// Extracts the first 2 elements from the tupletype Example = TakeFirstKeys<QueryListKey<'post'>, 2>;// Result: ['get-list', 'post']
A utility type that extracts the first
N
elements from a tuple typeT
. If the tupleT
has fewer thanN
elements, it returns the entire tuple.This type is implemented recursively:
T
to the result arrayR
.R
reachesN
.