stack

Home > @infiniteobjects/type-utils > SetRequired

SetRequired type

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

Signature:

export type SetRequired<BaseType, Keys extends keyof BaseType> = Simplify<Except<BaseType, Keys> & Required<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 required.