Skip to main content

Function: safeObjectOmit()

safeObjectOmit<T, K>(obj: undefined | null | T, keys: readonly K[]): Omit<T, K>

Defined in: shared/utils/objectSafety.ts:121

Create a type-safe object with specified keys omitted.

Type Parametersโ€‹

Tโ€‹

T extends Record<PropertyKey, unknown>

Kโ€‹

K extends string | number | symbol

Parametersโ€‹

objโ€‹

Source object

undefined | null | T

keysโ€‹

readonly K[]

Keys to omit from the object

Returnsโ€‹

Omit<T, K>

New object without the specified keys

Exampleโ€‹

const user = {
id: 1,
name: "John",
email: "john@example.com",
password: "secret",
};
const publicUser = safeObjectOmit(user, ["password"]);
// Type: { id: number; name: string; email: string; }