Type alias ObjectToEntries<OBJ>

ObjectToEntries<OBJ>: {
    [K in keyof OBJ as number]: [K, OBJ[K]]
}[number]

takes an object and returns an array of 2-tuples (entries) containing the key-value pairs in the form of [key: string, value: any]. it practically functions like the elements of Object.entries. ObjectFromEntries does the inverse of what this does.

Type Parameters

  • OBJ

Example

type MyObj = { name: "john", age: 30, title: string }
type MyEntries = ObjectToEntries<MyObj>
// type MyEntries === (["name", "john"] | ["age", 30] | ["title", string])

Generated using TypeDoc