TYPESCRIPT

TypeScript Omit Type: Syntax, Use Cases, and Examples

The TypeScript omit utility type allows you to create a new type by excluding specific properties from an existing one. It is one of the most useful features for shaping object types in a precise and reusable way. By removing certain fields from a type, you can build cleaner abstractions, reduce duplication, and improve type safety in applications that depend on complex object models.

In this guide, you'll explore how omit TypeScript works, how to use it effectively with both simple and nested structures, and how it compares to similar utilities like Pick. You’ll also learn techniques for omitting multiple fields, applying it with enums, and creating deep omission utilities.


What Is TypeScript Omit?

The TypeScript Omit type is a built-in utility that constructs a new type by removing one or more properties from another type. It takes two arguments:

Omit<Type, KeysToRemove>

The first argument is the base type, and the second is a union of keys to exclude. The resulting type contains all the properties of the base type, except those specified in the second argument.

This utility is extremely useful when you want to reuse an existing type but exclude sensitive, irrelevant, or unneeded fields.


Syntax of Omit TypeScript

The basic syntax is:

type NewType = Omit<OriginalType, 'fieldToRemove'>;

You can also omit multiple properties by passing a union of keys:

type ReducedType = Omit<OriginalType, 'a' | 'b' | 'c'>;

Here's an example with a user profile:

type User = {
  id: string;
  name: string;
  email: string;
  password: string;
};

type PublicUser = Omit<User, 'password'>;

In this example, PublicUser includes all fields from User except for password.


Why Use the TypeScript Omit Type?

Using omit TypeScript improves code maintainability by avoiding repetition. If you define a User interface and need a version without the password or internal identifiers, you don’t have to recreate the type manually.

This utility also plays an important role in security and data handling. It helps prevent the accidental exposure of sensitive fields in API responses, logs, or UI components.

By ensuring excluded fields are removed at the type level, developers reduce the risk of accessing or displaying restricted information.


TypeScript Omit Type Example: Removing a Field

Suppose you have a type for a product:

type Product = {
  id: number;
  name: string;
  price: number;
  internalCode: string;
};

type PublicProduct = Omit<Product, 'internalCode'>;

Now, PublicProduct will not have the internalCode field, making it safe to expose in public contexts like API responses.


How to Omit Multiple Fields in TypeScript

To omit more than one property, use a union of field names:

type Employee = {
  id: number;
  name: string;
  salary: number;
  department: string;
  position: string;
};

type PublicEmployee = Omit<Employee, 'salary' | 'department'>;

This creates a version of Employee without the salary and department fields, which may be useful in client-side views or shared contexts.

Using typescript omit multiple properties like this ensures you retain the structure of the original type while stripping away unneeded parts.


TypeScript Pick and Omit Combined

In some cases, you may want to pick specific fields first, then omit a subset of them. You can chain Pick and Omit together:

type FullUser = {
  id: string;
  name: string;
  email: string;
  password: string;
  role: string;
};

type LimitedUser = Omit<Pick<FullUser, 'id' | 'name' | 'email' | 'role'>, 'role'>;

This results in a type with only id, name, and email. Combining TypeScript pick and omit enables more precise shaping of data, especially in scenarios with overlapping type requirements across components or services.


Enum Omit TypeScript

When working with enums, Omit can be used to filter object types that use enum values as keys. However, enums themselves can’t be directly altered with Omit. Instead, you omit keys from types derived from enums.

enum Status {
  Active = 'active',
  Inactive = 'inactive',
  Archived = 'archived'
}

type StatusMessages = {
  [key in Status]: string;
};

type ActiveMessages = Omit<StatusMessages, Status.Archived>;

This results in a type that maps only Active and Inactive statuses to messages, excluding Archived.

Using enum omit TypeScript in this way ensures precise control over enum-based type mappings.


Deep Omit TypeScript

The built-in Omit utility only works at the top level. To exclude nested fields, you need to define a custom DeepOmit utility. Here’s a basic example using recursive conditional types:

type DeepOmit<T, K> = {
  [P in keyof T as P extends K ? never : P]: T[P] extends object
    ? DeepOmit<T[P], K>
    : T[P];
};

And to use it:

type ComplexUser = {
  id: string;
  profile: {
    name: string;
    password: string;
  };
};

type SafeUser = DeepOmit<ComplexUser, 'password'>;

Now, SafeUser will recursively remove all password fields from any depth of nesting. This deep omit TypeScript pattern is useful in large applications with deeply nested objects, like user configurations or form states.


Practical Use Cases for TypeScript Omit

The TypeScript omit type appears across many real-world applications. For instance, in form handling, you might want to omit backend-only fields like id or createdAt before sending the form data to a save function.

In frontend development, it’s common to reuse models from the backend but exclude fields not needed by the UI. For example, a component might use Omit<Product, 'internalCode' | 'supplierId'> to ensure it only receives display-ready fields.

In testing and mocking scenarios, you can create simplified versions of objects without unnecessary details:

type TestUser = Omit<User, 'password' | 'createdAt'>;

This streamlines test setup while maintaining type safety.


Type Safety and IDE Support

When using omit TypeScript, your editor will show helpful autocompletion and warnings. If you try to access an omitted property, TypeScript will raise a type error. This prevents you from unintentionally using restricted fields or passing incompatible objects.

TypeScript also provides improved refactoring support when using Omit. If you rename a property in the base type, the omitted field name will automatically update, avoiding silent mismatches.

These benefits help you enforce consistency and prevent bugs as your application grows.


Performance and Maintainability

Since Omit is a compile-time construct, it has zero performance impact at runtime. The emitted JavaScript code contains no traces of the type—it’s purely used for development tooling. This means you can freely use it in large codebases without concern for performance.

Maintainability also improves, since you can build flexible, reusable APIs without redefining overlapping types. Instead of duplicating object shapes with slight variations, you can build them using Omit and keep a single source of truth.


Summary

The TypeScript omit utility type provides a powerful way to reshape existing object types by excluding one or more properties. It is especially useful in scenarios involving data sanitization, role-based access control, testing, UI constraints, and configuration handling. By using omit TypeScript, you maintain consistent and type-safe representations of your objects without unnecessary redundancy.

You can omit multiple fields, combine Omit with Pick, use it with enums, or even build deep omission utilities for complex types. Across use cases, this utility helps enforce cleaner contracts between different parts of your application and ensures your code remains adaptable and robust.

Learn TypeScript for Free
Start learning now
button icon
To advance beyond this tutorial and learn TypeScript by doing, try the interactive experience of Mimo. Whether you're starting from scratch or brushing up your coding skills, Mimo helps you take your coding journey above and beyond.

Sign up or download Mimo from the App Store or Google Play to enhance your programming skills and prepare for a career in tech.

You can code, too.

© 2025 Mimo GmbH

Reach your coding goals faster