0Pricing
TypeScript Academy · Lesson

Pick and Omit: Selecting Properties

Create subtypes by including or excluding keys.

Welcome

Pick creates a type with only the specified properties. Omit creates a type without the specified properties. They are complementary tools for shaping object types.

Pick<T, K>

Keep only the listed keys from T.
interface User { id: number; name: string; email: string; role: string; }
type PublicUser = Pick<User, 'id' | 'name'>;
// { id: number; name: string }

All lessons in this course

  1. Partial and Required: Toggling Optionality
  2. Pick and Omit: Selecting Properties
  3. Record: Mapping Keys to Value Types
  4. Readonly, Exclude, Extract, NonNullable
← Back to TypeScript Academy