Delete Object Fields
Creates a new object by removing specified properties from a source object.
deleteFields
The deleteFields function creates a new object by removing specified properties from a source object, preserving accurate TypeScript types.
Function Signature
function deleteFields<T extends GenericObject, U extends keyof T>(
source: T,
keys: readonly U[]
): { [K in Exclude<keyof T, U>]: T[K] }Parameters
source(T): The source object to copy.keys(readonly U[]): An array of property keys to exclude from the cloned object.
Return Value
{ [K in Exclude<keyof T, U>]: T[K] }: A new object excluding the specified properties.
Example Usage
playground.ts
Notes
- This function operates on top-level properties only. It does not support deep deletion or dot-notation paths.
- It is non-destructive and returns a new object without mutating the original
source.
Aliases
The following aliases can be used for the deleteFields function:
omitFieldsomitObjectFieldsdeleteObjectFieldsremoveFieldsremoveObjectFields
See Also
- pickFields - Select specific object fields.
- pickFieldsByCondition - Conditionally select object fields.
- remapFields - Rename object keys.
Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)
