Course contentsShow
← TypeScript
Lesson 675 of 1,79616. Utility TypesFree lesson

Pick<T, K>: Selecting a Subset of Properties

Learn how Pick creates a new type by selecting specific properties from an existing object type.

Pick<T, K>: Selecting a Subset of Properties

What you'll learn: How to use Pick<T, K> to create a new type containing only specific properties from an existing object type.

What Pick Does

Pick<T, K> is a utility type that lets you "cherry-pick" certain properties from an object type to create a smaller, more focused type. Think of it like ordering à la carte at a restaurant—you're choosing only the items you want from the full menu, not the entire set meal.

The Syntax

Pick<OriginalType, 'property1' | 'property2'>
  • T is the original type you're picking from
  • K is a union of string literal keys you want to keep

Basic Example

type User = {
  id: number;
  name: string;
  email: string;
  age: number;
  isActive: boolean;
};

// Pick only name and email
type UserPreview = Pick<User, 'name' | 'email'>;

// UserPreview is now:
// {
//   name: string;
//   email: string;
// }

const preview: UserPreview = {
  name: "Alice",
  email: "alice@example.com"
  // id, age, and isActive are NOT allowed here
};

Why Use Pick?

Instead of manually rewriting subsets of types, Pick keeps them synchronized with the source type. If User.email changes from string to EmailAddress (a custom type), UserPreview automatically reflects that change.

Key Takeaway: Pick<T, K> creates a new type by selecting only the properties specified in K from type T, keeping your types DRY and automatically synchronized with their source.