Function unpartial

  • Unpartial a partial type.

    Type Parameters

    • T extends Record<any, any>

    • R extends Record<any, any> = Partial<T>

    Parameters

    • base: T

      The base value to fill in needed property if not available in the partial value.

    • partial: undefined | null | R

      The partial value to be unpartialed.

    Returns Exclude<keyof R, keyof T> extends infer K
        ? [K] extends [never]
            ? {
                [P in keyof T]: P extends keyof R
                    ? T[P] | Exclude<R[P], undefined>
                    : T[P]
            }
            : {
                [P in keyof T]: P extends keyof R
                    ? T[P] | Exclude<R[P], undefined>
                    : T[P]
            } & Pick<R, K>
        : never

  • Unpartial a partial type with two base values. This is useful when you are extending value from another package or code. That means you have a parent value from the original code, a base value where you add additional defaults or override existing one, and partial value from input.

    Type Parameters

    • T extends Record<any, any>

    • R extends Record<any, any> = Partial<T>

    • S extends Record<any, any> = Partial<T & R>

    Parameters

    • parent: T

      The default value from the original code.

    • base: undefined | null | R

      The extended default value of your code.

    • partial: undefined | null | S

      The input value.

    Returns T & R & S

    Deprecated

    please use composition instead: unpartial(unpartial(a, b), c)

Generated using TypeDoc