Skip to content

Function.omitDeep

github-actions[bot] edited this page Nov 18, 2026 · 13 revisions

umt / omitDeep

Function: omitDeep()

omitDeep<T, K>(object, ...keys): OmitDeep<T, K>

Defined in: Object/omitDeep.ts:41

Creates a new object by deeply removing properties from the source object based on specified keys. This is the counterpart of pickDeep.

Each key is removed with unset, so plain objects and arrays along a path are shallow-copied and the source object is not mutated. Keys that do not exist are ignored.

Type Parameters

T

T extends object

Type of the source object.

K

K extends readonly PickDeepKey<T>[]

Type of property keys to remove. Must be a subset of PickDeepKey.

Parameters

object

T

The source object to remove properties from.

keys

...K

Property keys to remove. Can use dot notation for nested properties.

Returns

OmitDeep<T, K>

A new object without the specified properties.

Remarks

Prototype pollution warning: This function does not filter out prototype-polluting keys (__proto__, constructor, prototype). Sanitize user-controlled keys before calling.

Example

const obj = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 };
const omitted = omitDeep(obj, "a.b.c", "f");
// omitted will be { a: { b: { d: 2 }, e: 3 } }

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally