Skip to content

SetNullable

SetNullable<BaseType, Keys> = Simplify<Except<BaseType, Keys> & { [K in Keys]: BaseType[K] | null }>

Defined in: packages/core/src/types/util/set-nullable.ts:28

Utility type that makes the specified keys of an object type nullable (i.e., allows them to be null).

Example:

type A = SetNullable<{ a: string; b: number; c: boolean }, "a" | "c">;
// Result: { a: string | null; b: number; c: boolean | null }

If no keys are specified, all properties of the object type will be made nullable.

Example:

type B = SetNullable<{ a: string; b: number }>;
// Result: { a: string | null; b: number | null }

BaseType

The base object type.

Keys extends keyof BaseType = keyof BaseType

The keys of the object type to make nullable. Defaults to all keys of the object type.