@ac-essentials/misc-util
    Preparing search index...

    Type Alias SetNullable<BaseType, Keys>

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

    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 }

    Type Parameters

    • 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.