Type alias ObjectFromEntries<T>

ObjectFromEntries<T>: {
    [K in EntriesToKeys<T>]: Extract<T[number], [K, any]>[1]
}

takes an array of 2-tuples (entries) of the form [key: string, value: any], and returns an interface with with the same key-value pairs. it practically functions like Object.fromEntries. ObjectToEntries does the inverse of what this does.

Type Parameters

  • T extends [string, any][]

Example

type MyObj = ObjectFromEntries<[["name", "john"], ["age", 30], ["title", string]]>
// type MyObj === { name: "john", age: 30, title: string }

Generated using TypeDoc