Deep Utility Types

1.3.1 · active · verified Sun Apr 19

Deep Utility Types is a TypeScript-focused library providing advanced utility types for performing operations like `Omit`, `Pick`, `Require`, and `Optional` on nested object structures. Unlike standard TypeScript utility types, this library supports dot-notation for accessing and modifying properties at any depth within an object, including handling arrays. It is fully type-safe, offers excellent autocompletion support in IDEs, and includes a mechanism for ignoring specific types (like large classes or built-ins) to improve type-checker performance and reduce noise in autocompletion suggestions. The current stable version is 1.3.1, with releases typically focusing on bug fixes and incremental features, such as exposing internal types for broader use. Its primary differentiator is its robust deep-nesting support and type-safety for complex object manipulations, which is not natively provided by TypeScript.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to use `DeepOmit` to create a new type by removing specified nested properties using dot notation.

import { DeepOmit } from 'deep-utility-types';

type UserProfile = {
  id: string;
  name: string;
  contact: {
    email: string;
    phone: string;
    address: {
      street: string;
      city: string;
      zip: string;
    };
  };
  settings: {
    notifications: boolean;
    theme: 'light' | 'dark';
  };
};

// Create a type that omits the user's phone number and notification setting
type PublicUserProfile = DeepOmit<UserProfile, 'contact.phone' | 'settings.notifications'>;

const user: PublicUserProfile = {
  id: 'user-123',
  name: 'John Doe',
  contact: {
    email: 'john.doe@example.com',
    address: {
      street: '123 Main St',
      city: 'Anytown',
      zip: '12345',
    },
  },
  settings: {
    theme: 'dark',
  },
};

console.log(user);

view raw JSON →