Typed alternative to Object.keys() that preserves key inference.
Object.keys()
Object whose own enumerable string keys to collect.
An array typed as (keyof T)[] rather than string[].
(keyof T)[]
string[]
const obj = { foo: 1, bar: "hello" };const keys = typedKeys(obj);// ^? ("foo" | "bar")[] Copy
const obj = { foo: 1, bar: "hello" };const keys = typedKeys(obj);// ^? ("foo" | "bar")[]
Typed alternative to
Object.keys()that preserves key inference.