Know if you're actually ready. Take the TypeScript quiz → get your AI readiness report.Take the free test →

Study guide · TypeScript

TypeScript Pick and Omit — Select and Exclude Properties

Pick selects a subset of properties from a type. Omit excludes specific properties. Both are essential for shaping types without duplication.

What TypeScript Pick does

Pick<T, K> creates a new type containing only the properties you name. K must be a union of keys that exist on T — TypeScript enforces this at compile time.

interface User {
    id: string;
    name: string;
    email: string;
    password: string;
    role: 'admin' | 'user';
    createdAt: Date;
}

// Select only the properties you need
type PublicUser = Pick<User, 'id' | 'name' | 'email'>;
// Result: { id: string; name: string; email: string; }

// Pick a single property
type UserEmail = Pick<User, 'email'>;
// Result: { email: string; }

// TypeScript error — 'phone' does not exist on User
// type Bad = Pick<User, 'phone'>;  ❌

What TypeScript Omit does

Omit<T, K> is the inverse of Pick — it creates a type with all properties except the ones you name. Use it when it's easier to say what you don't want.

// Omit specific properties
type UserWithoutPassword = Omit<User, 'password'>;
// { id, name, email, role, createdAt } — password is gone

// Omit multiple properties
type PublicUserOmit = Omit<User, 'password' | 'createdAt'>;
// { id, name, email, role }

// Omit vs Pick: same result, different intent
type A = Pick<User, 'id' | 'name' | 'email'>;
type B = Omit<User, 'password' | 'role' | 'createdAt'>;
// A and B are structurally identical

Real-world pattern: API request and response types

Pick and Omit are most useful when you have one canonical type but need variants for different contexts — creating, updating, and returning data.

interface Product {
    id: string;
    name: string;
    price: number;
    stock: number;
    createdAt: Date;
    updatedAt: Date;
}

// POST /products — no id or timestamps (server generates them)
type CreateProduct = Omit<Product, 'id' | 'createdAt' | 'updatedAt'>;

// PATCH /products/:id — all fields optional except id
type UpdateProduct = Pick<Product, 'id'> & Partial<Omit<Product, 'id' | 'createdAt' | 'updatedAt'>>;

// GET /products — never expose stock in public API
type PublicProduct = Omit<Product, 'stock'>;
NoteCombining Pick/Omit with Partial is the standard pattern for PATCH endpoints: required id, everything else optional.

Pick with generics — building reusable utilities

Pick and Omit become especially powerful when combined with generics. You can write functions that work with any type while maintaining full type safety.

// A generic function that returns only specified fields
function selectFields<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {
    return keys.reduce((acc, key) => {
        acc[key] = obj[key];
        return acc;
    }, {} as Pick<T, K>);
}

const user: User = { id: '1', name: 'Alice', email: 'a@b.com', password: 'x', role: 'user', createdAt: new Date() };

const publicUser = selectFields(user, ['id', 'name', 'email']);
// TypeScript infers: Pick<User, 'id' | 'name' | 'email'>
// publicUser.password  ← TypeScript error ✓

How Pick and Omit are implemented

Understanding the implementation helps you write similar mapped types yourself. Both use mapped types and the keyof operator under the hood.

// Pick is implemented as a mapped type:
type MyPick<T, K extends keyof T> = {
    [P in K]: T[P];
};

// Omit uses Exclude to remove keys first:
type MyOmit<T, K extends keyof T> = {
    [P in Exclude<keyof T, K>]: T[P];
};

// These are equivalent to the built-in types
type Test1 = MyPick<User, 'id' | 'name'>;    // { id: string; name: string; }
type Test2 = MyOmit<User, 'password'>;         // User without password
NoteYou'll be asked to implement Pick from scratch in senior interviews. The pattern is: mapped type + K extends keyof T constraint.
Exam tipThe key exam point: Pick<T, K> requires K extends keyof T — TypeScript will reject invalid keys at compile time. Omit is Pick's inverse. Know when to use each: Pick when you want a small subset; Omit when it's easier to list what to remove.

Want a person to help?

Struggling with TypeScript? Work 1:1 with a vetted TypeScript tutor on Wyzant. (affiliate link)

Find a TypeScript tutor →
← All TypeScript guides