MakeNullishOptional<T>: PartialBy<T, NullishPropertiesOf<T>>

Makes all shallow properties of an object optional if they accept undefined or null as a value.

Type Parameters

  • T extends object

Example

type MyOptionalType = MakeUndefinedOptional<{
id: number | undefined,
firstName: string,
lastName: string | null,
}>;

// is equal to

type MyOptionalType = {
// this property is optional.
id?: number | undefined,
firstName: string,
// this property is optional.
lastName?: string | null,
};