TypeScript 7 · Types

Get the keys of a type

Build a union of an object type's keys.

type UserKey = keyof User; // "id" | "name" | "email"

Official TypeScript 7 documentation

More types commands

All types commands · TypeScript 7 cheatsheet

Was this page helpful?