type Key = string | number | symbol export function fromList(xs: Array<{key: Key, value: V}>): Record { let res: any = {} xs.forEach(o => res[o.key] = o.value) return res as Record } export function toList(record: Record): Array<{key: Key, value: V}> { return Object.keys(record) .map(key => ({ key: key, value: record[key] })) } type EnumObject = {[key: string]: number | string}; type EnumObjectEnum = E extends {[key: string]: infer ET | string} ? ET : never; export function values(enumObject: E): EnumObjectEnum[] { return Object.keys(enumObject) .filter(key => Number.isNaN(Number(key))) .map(key => enumObject[key] as EnumObjectEnum) }