Function requireNonNilElseThrow

  • Throws an exception if the value is nil, returns the value otherwise.

    Since

    13.0.0

    Returns

    The value provided with guarantee to be non-nil.

    Throws

    Error if value is nil.

    Example

    requireNonNilElseThrow("foo", () => new TypeError())
    // => "foo"

    requireNonNilElseThrow(null, () => new TypeError())
    // => throws TypeError

    Type Parameters

    • T

    Parameters

    • value: undefined | null | T

      Value to check.

    • errorSupplier: (() => Error)

      Supplier for the error to be thrown.

        • (): Error
        • Returns Error

    Returns T

Generated using TypeDoc