Skip to content

Create generics utility for objects #46

@manni497

Description

@manni497

Create utilities for objects exploiting generics like

type NullableKeys<T> = {
  [P in keyof T as undefined extends T[P] ? P : never] : T[P]
}
// delete all properties from object (but only optional)
export const deleteObjectProperties = <T extends object>(object: T, propertiesToDelete: (keyof NullableKeys<T>)[]) => propertiesToDelete.forEach(property => delete object[property]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions