keyof

The TypeScript type operator that produces a union of an object type's property names, such as "id" | "table" | "rowCount".

In more detail

keyof is the basis of type-safe property access: K extends keyof T lets a function accept only real keys of T, so typos fail to compile and editors suggest valid names. Keys can be strings, numbers or symbols.

Related terms

Taught in

References