...

/

Utility Types: Pick, Omit, Partial, and Required

Utility Types: Pick, Omit, Partial, and Required

Master the most useful built-in utility types to write cleaner, safer, and more maintainable TypeScript.

When we think about types, most of us start with a simple mental model: types describe shapes of data. But TypeScript takes it further. Types can also generate other types. They can reshape, trim, expand, or adapt structures just like functions do with values.

These are called utility types, and they let us transform existing object types with precision and purpose. Want to make every field optional? Or pick just a few properties from a complex type? Or build a dictionary of typed values? Utility types make all of that possible without rewriting anything from scratch.

In this lesson, we’ll break down the utility types that matter most in real-world projects: PickOmitPartial, and Required. We’ll see how they streamline our code, enforce better contracts, and unlock new patterns for data modeling.

Pick: Extract a clean subset of fields

Often, we only want some of a type’s fields. Whether it’s exposing a safe public view of a user object or feeding limited data into a component, Pick lets us create a focused version of the type, keeping only the fields we specify.

Press + to interact
TypeScript 5.8.3
Files
type FullUser = {
id: string;
name: string;
email: string;
passwordHash: string;
};
type PublicUser = Pick<FullUser, "id" | "name">;
const view: PublicUser = {
id: "u123",
name: "Zara",
};
console.log(view);

Explanation:

  • Lines 1–6: The full user model includes everything, including sensitive data like passwordHash.

  • Line 8: Pick creates a new type that includes only id and name.

  • Lines 10–13: Because PublicUser only includes id and name, TypeScript will throw a compile time error if we try to add any other field.

Omit: Remove specific fields from a type

Sometimes it’s easier to describe what we don’t want. Maybe a field is internal, sensitive, or just irrelevant in a certain context. Omit takes a type and removes ...

Access this course and 1400+ top-rated courses and projects.