Given the following object:
const obj = { a: 1, b: 2, c: 3 };
I would like to build a type that returns:
type ObjKeysAsArray<T> = ?; // ObjKeysAsArray<typeof obj>: ["a", "b", "c"]
I thought about (keyof typeof obj)[], but it would return ("a" | "b" | "c")[], which is not what I want.
{a: number, b: number, c: number}is the same as{b: number, a: number, c: number}) and union types are also not observably ordered. So there is no way to get an ordered tuple type fromkeyof typeof objthat's guaranteed to give you the same order asObject.keys(obj).