omit

Commons
stable

Returns a shallow clone of an object with the specified keys removed. The original object is not mutated. TypeScript narrows the return type to Omit<T, U>.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

obj
required
T
The source object. A shallow clone is created before removing keys.
exclude
required
Array<U>
Array of key names to exclude from the clone. TypeScript enforces that each key exists on T.

API

Return value

The value returned by this util.

A new object of type Omit<T, U> containing all properties of obj except those listed in exclude.

Usage

Examples

Ready-to-paste usage snippets.

Remove internal props before passing to a child

typescript