Function defaultTo

A function that receives a defaultValue and returns a new function that receives a value. If the value is null, or undefined, the defaultValue is returned, otherwise the value is returned.

  • Type Parameters

    • R

    Parameters

    • defaultValue: R

    Returns <T>(
        value?: T,
    ) => T extends NonNullable<T>
        ? T<T>
        : NonNullable<T> extends never ? R : R | T