Type alias PartialExcept<T, K>

PartialExcept<T, K>: {
    [P in K]: T[P]
} & Partial<Omit<T, K>>

PartialExcept<T, K extends keyof T> is a utility type that makes all properties of T optional except for the properties specified in K, which are required. This is useful for scenarios where you want to enforce that certain fields must be present while allowing others to be omitted.

Type Parameters

  • T

    The original type from which to derive the new type.

  • K extends keyof T

    A subset of keys from T that should remain required in the resulting type.

Example

type User = {
id: number;
name: string;
email: string;
};

type UserUpdate = PartialExcept<User, 'email'>; // Result: { id?: number; name?: string; email: string; }