stack

Home > @infiniteobjects/type-utils > SetOptionalKeys

SetOptionalKeys type

Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the SetRequired type.

Signature:

export type SetOptionalKeys<BaseType, Keys extends keyof BaseType> = Simplify<Except<BaseType, Keys> & Partial<Pick<BaseType, Keys>>>;

References: Simplify, Except

Remarks

Useful to define a single model where the only thing that changes is whether or not some of the keys are optional.