TypeScript Utility Types Explained: Pick, Omit, and Partial in Real Code

TypeScript Utility Types Explained: Pick, Omit, and Partial in Real Code

Most TypeScript codebases end up with one big interface that describes a thing, and then a dozen smaller shapes derived from it: the version the API sends back, the version a form collects, the version an update endpoint accepts. TypeScript utility types exist for exactly this problem. Pick, Omit, and Partial take a type you already have and reshape it, so you write the shape once and let the compiler build the rest. This guide walks through all three with short, working code you can paste into your own project, plus the real situations where each one earns its place.

If you are still moving a codebase from JavaScript, the migration itself is where these helpers first pay off. A good step-by-step guide to migrating a JavaScript project to TypeScript shows how to add types gradually instead of rewriting everything at once, and once your core interfaces exist, Pick, Omit, and Partial keep them from multiplying into near-duplicates.

What Pick, Omit, and Partial Actually Do

All three are built into TypeScript, so there is nothing to install. Each one takes an existing type and returns a new type:

  • Pick keeps only the fields you name and drops the rest.
  • Omit drops the fields you name and keeps the rest.
  • Partial keeps every field but makes each one optional.

They work at compile time only. Nothing changes at runtime, and no extra JavaScript ships to the browser. That is the whole point: you get safer code without paying for it in bundle size. Searches for pick omit partial typescript usually land on the same three definitions, but the definitions alone do not tell you when to reach for which one. The examples below use one shared interface so you can see how the same starting point leads to three different results.

interface User {
  id: string;
  name: string;
  email: string;
  passwordHash: string;
  createdAt: Date;
}

Five fields, one source of truth. Everything that follows derives from this interface, so a change here flows into every derived type automatically.

How TypeScript Utility Types Work

Under the hood, these helpers are generic types that map over the keys of another type. Pick builds a new object type from a subset of keys, Omit builds one from the remaining keys, and Partial wraps every property in an optional marker. You do not need to understand mapped types to use them well, but knowing they are plain type-level operations explains why they compose so cleanly: the output of one can feed straight into another.

For example, you can combine them when a shape needs two changes at once. A profile edit form might need only some fields, and all of them optional:

type EditableProfile = Partial<Pick<User, "name" | "email">>;

// Same as: { name?: string; email?: string }

The compiler reads this left to right: take name and email from User, then make both optional. If you later rename a field in User, the compiler flags every place that still uses the old name. That is the real payoff. Hand-written copies of a type drift apart silently; derived types stay in sync because there is only one place to change.

When you are deciding whether TypeScript is worth the effort at all, it helps to weigh the trade-offs first. Our comparison of TypeScript vs JavaScript in 2026 looks at where the type system helps and where plain JavaScript is still the simpler choice.

Pick: Build a Smaller Type From a Bigger One

Pick is the right tool when you need a few fields from a large type and want the compiler to enforce exactly which ones. The classic case is a public API response. Your database row holds a password hash, but the client must never see it:

type PublicUser = Pick<User, "id" | "name" | "email">;

const publicUser: PublicUser = {
  id: "u_123",
  name: "Maya",
  email: "[email protected]",
};

// Error: "passwordHash" does not exist on type PublicUser
const bad = { ...publicUser, passwordHash: "secret" };

The typescript pick type pattern shows up everywhere a boundary exists between two parts of a system: API responses, list views that show three columns out of twenty, and props passed to a card component that only needs an id and a name. Pick names the fields you want, which makes the intent obvious to the next person reading the code. If someone adds a sensitive field to User later, it stays out of PublicUser until somebody deliberately adds it.

Pick works best when the subset is small and stable. If you find yourself picking eight of ten fields, Omit is probably the clearer choice, because naming the two you want to drop says more than listing the eight you keep.

Omit: Remove Fields You Do Not Need

Omit is Pick in reverse: name the fields to drop and keep everything else. It shines when the type you need is almost the original, minus one or two fields. A create-user form is the textbook example. The server generates the id and the timestamp, so the client should not send them:

type NewUserInput = Omit<User, "id" | "createdAt">;

function createUser(input: NewUserInput) {
  // id and createdAt are added by the server
  return db.users.insert(input);
}

createUser({
  name: "Maya",
  email: "[email protected]",
  passwordHash: "hashed-value",
});

The typescript omit type is also handy for stripping fields before logging or caching. Drop the password hash before writing a user object to a log file, and the compiler will catch it if someone later tries to log the full object by mistake. A related use is building a type for a child component that receives everything except an internal field its parent manages.

One warning: Omit only drops top-level keys. If a field holds a nested object, Omit cannot reach inside it. For nested shapes you need a deeper helper or a separate interface for the nested part.

Partial: Make Every Field Optional

Partial turns every property of a type into an optional one. Its most common job is the PATCH endpoint: a client sends only the fields it wants to change, and the server merges them into the stored record.

async function updateUser(
  id: string,
  patch: Partial<User>
): Promise<User> {
  const current = await db.users.findById(id);
  return db.users.save({ ...current, ...patch });
}

// Only the name changes; everything else stays put
await updateUser("u_123", { name: "Maya Chen" });

The typescript partial type also fits config objects and test fixtures. A function that accepts a settings object with ten options can take Partial of the settings type and fill in defaults for anything missing. In tests, a factory function can accept a partial object and merge it over sensible defaults, so each test only states the fields it cares about.

Partial has one trap worth knowing: it makes fields optional, but it does not make them nullable. A field typed as string becomes string or undefined, never null. If your API sends explicit nulls, you need a different approach, such as mapping each field to a union with null yourself.

Picking the Right One in Real Code

When the three overlap, decide by what you are saying about the shape. Pick says “I need exactly these fields.” Omit says “I need everything except these.” Partial says “I need the same shape, but any field may be missing.” That sentence is usually enough to choose.

A few habits keep these helpers from turning into a mess. Derive from one shared interface instead of chaining helpers across three different types, because long chains are hard to read. Avoid deriving a type from another derived type when a fresh Pick from the original says the same thing in one step. And when a derived shape starts to feel permanent, give it a real name and a comment that says why it exists. PublicUser and NewUserInput read better than inline Pick and Omit scattered through function signatures.

These helpers sit alongside the newer language features worth knowing. Our roundup of TypeScript 5.x features worth using today covers what else arrived recently, and the same “derive, do not duplicate” idea shows up in broader design work too. The design patterns every developer should know guide explains the patterns that keep larger codebases organized once your types start to grow.

Start with the interface you already have. The next time you catch yourself copying it into a smaller version by hand, stop and reach for Pick, Omit, or Partial instead. One source of truth, three small helpers, and a codebase where a rename in one place updates everywhere it matters.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.