keyof T creates a union of an object type’s property names. Array<keyof T> represents a list of those names. When you call Object.keys, you get string[], so you often cast the result to Array<keyof T> to keep types precise.
function keysOf<T extends object>(o: T): Array<keyof T> {
return Object.keys(o) as Array<keyof T>;
}
Prefer returning a new array. Assume normal insertion order from JavaScript objects when testing with literals.
Create a function that returns the typed keys of an object.