Type Alias PickOptional<T, K>

PickOptional<T, K>: {
    [P in K]?: T[P]
} & Omit<T, K>

Picks a subset of properties from a type and makes them optional.

Type Parameters

  • T

    The type to pick properties from.

  • K extends keyof T

    The keys of the properties to pick.

type Test = PickOptional<{ a: number; b: string; c: boolean }, "a" | "b">; // { a?: number; b?: string; c: boolean; }