Skip to content

Tuple

Helper functions that have to do with TypeScript tuples.

function tupleEntries<T>(tuple): Generator<TupleEntry<T>>;

Defined in: functions/tuple.ts:21

Helper function to get the entries (i.e., indexes and values) of a tuple in a type-safe way.

This is useful because the vanilla Array.entries method will always have the keys be of type number.

Type Parameter
T extends readonly unknown[]
Parameter Type
tuple T

Generator<TupleEntry<T>>


function tupleKeys<T>(tuple): Generator<TupleKey<T>>;

Defined in: functions/tuple.ts:33

Helper function to get the keys (i.e., indexes) of a tuple in a type-safe way.

This is useful because the vanilla Array.keys method will always have the keys be of type number.

Type Parameter
T extends readonly unknown[]
Parameter Type
tuple T

Generator<TupleKey<T>>