This is a utility type that allows you to get the keys from an object or list.
If T is a type of list, then this behaves the same as ValuesOf.
const MyEnum = { foo: 'bar', another: 'baz' } as const;
const MyList = ['apple', 'banana', 'orange'] as const;
const MyEnum = { foo: 'bar', another: 'baz' } as const; const MyList = ['apple', 'banana', 'orange'] as const;
function example(param: KeyOf<typeof MyEnum>): void { // param would be: "foo" | "another" }
function example2(param: KeyOf<typeof MyList): void { // param would be: "apple" | "banana" | "orange" }