Delete property of generic type

Combining a destructure with the Omit type, you could do something like:

export const deleteProperty = <T, K extends keyof T>(obj: T, id: K): Omit<T, K> => {
    const { [id]: _, ...newState } = obj;
    return newState;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top