Pick⟨Type, Keys⟩ Utility Type in TypeScript

Опубликовано: 03 Июнь 2026
на канале: Learn Language Hub
9
0

What is Pick⟨Type, Keys⟩ in TypeScript

Pick⟨Type, Keys⟩ is a utility type in TypeScript that creates a new type by selecting specific properties from an existing type.

In simple terms:

It takes an object type and keeps only the properties you choose.

Basic idea

Conceptually:

Pick⟨Type, Keys⟩


means:

Create a new type with only Keys from Type

Simple example
type User = {
id: number;
name: string;
email: string;
isAdmin: boolean;
};

type UserPreview = Pick⟨User, "id" | "name"⟩;

const user: UserPreview = {
id: 1,
name: "Alice",
};


Resulting type:

id is included

name is included

email is removed

isAdmin is removed

What happens if you add extra properties
const user: UserPreview = {
id: 1,
name: "Alice",
email: "[email protected]",
};
// Error: property "email" does not exist


Pick is strict: only the selected keys are allowed.

Very common use cases
1. API responses
type PublicUser = Pick⟨User, "id" | "name"⟩;


Expose only safe fields to the frontend or external clients.

2. Component props in React
type UserCardProps = Pick⟨User, "name" | "email"⟩;


Reuse existing types without duplicating definitions.

3. Reducing large types
type UserFlags = Pick⟨User, "isAdmin"⟩;


Extract just what you need for a specific use case.

How Pick works internally (mental model)

You can think of it like this:

type Pick⟨T, K extends keyof T⟩ = {
[Key in K]: T[Key];
};


Meaning:

Loop over each key in Keys

Copy that property from Type

Ignore everything else

Pick vs Partial

These are often combined but do different things:

Pick⟨Type, Keys⟩ → selects properties

Partial⟨Type⟩ → makes properties optional

Example:

type EditableUser = Partial⟨Pick⟨User, "name" | "email"⟩⟩;


This means:

Only name and email

Both are optional

Pick vs Omit

Pick⟨Type, Keys⟩ → choose what to keep

Omit⟨Type, Keys⟩ → choose what to remove

Example:

type UserWithoutEmail = Omit⟨User, "email"⟩;


Both are valid; Pick is often clearer when selecting a small subset.

Important things to know
1. Keys must exist on the type
Pick⟨User, "age"⟩;
// Error: "age" is not a key of User


TypeScript protects you from typos and invalid keys.

2. Pick is shallow

It only picks top-level properties, not nested ones.

When to use Pick⟨Type, Keys⟩

Use it when:

You want a subset of an existing type

You want to avoid duplicating type definitions

You want stricter, smaller object shapes

Avoid it when:

You need to transform property types

You need deep selection logic

One‑line summary

Pick⟨Type, Keys⟩ creates a new type with only the selected properties from Type.