typelab / utils / ObjectToTuple
type ObjectToTuple<T, IncludeNonIndex, HoleType, OmitHole> = IsArray<T> extends true ? T : IsObjectLiteral<T> extends true ? _ObjectToTuple<T, IncludeNonIndex, HoleType, OmitHole> : never;Converts an object into a Tuple of its values.
- If
IncludeNonIndexisfalse, only properties with numeric keys are included. - If
IncludeNonIndexistrue, all properties are included.
IncludeNonIndex is true.
| Type Parameter | Default type | Description |
|---|---|---|
|
|
‐ |
The |
|
|
|
A flag that determines whether to include non-array index or not. defaults to |
|
|
|
Safety type, if there is a hole(s) in result, defaults to |
|
|
|
Each element with |
A Tuple type, if T is ObjectLiteral or Tuple, never otherwise.
type Obj1 = { 0: string; 1: number; 2: boolean };
// [string, number, boolean]
type TupleType1 = ObjectToTuple<Obj1>;
type Obj2 = { a: 'a'; b: 'b'; c: 'c' };
// ['a', 'b, 'c']
type TupleType2 = ObjectToTuple<Obj2, true>;