There is no reason to make the custom failure callback a required parameter here because in most cases, there is no need fur such a custom handler.
/**
* Sends an AJAX requests to the server, simple wrapper to reuse the request object.
*/
- ajaxApi(data: RequestPayload, success: CallbackSuccess, failure: CallbackFailure): void {
+ ajaxApi(data: RequestPayload, success: CallbackSuccess, failure?: CallbackFailure): void {
if (typeof success !== "function") {
throw new TypeError("Expected a valid callback for parameter 'success'.");
}