EntriesOf<T>: {
    [K in keyof T]: [key: K, value: T[K]]
}[keyof T][]

map each entry (key-value pair) of an object, to a tuple of the key and its corresponding value.
the output of this type is what the builtin Object.entries static method should ideally return if it were typed strictly.

Type Parameters

  • T
const obj = { kill: "your", self: "ok", tomorrow: 420 } as const
type EntriesOfObj = EntriesOf<typeof obj>
// the IDE will now infer the type to be:
// `type EntriesOfObj = Array<["kill", "your"] | ["self", "ok"] | ["tomorrow", 420]>`
// had we not used the `as const` narrowing utility, the output would've then been:
// `type EntriesOfObj = Array<["kill", string] | ["self", string] | ["tomorrow", number]>`