Looking for a solution to implement a wrapper above the $http
service in an AngularJS project. The goal is to have request promises with an abort()
method.
Attempting to achieve this by creating the following function:
function request(params:ng.IRequestConfig):my.IRequestPromise {
var promise = $http(params).then(onSuccess, onError);
promise.abort = function () { // => here it fails with error "Property 'abort' does not exist on type 'IPromise<{}>'"
...
}
return promise;
}
Encountering an issue with TypeScript where it fails on the line defining abort
.
A custom interface called IRequestPromise
has been created which extends ng.IPromise
by adding an abort()
method. How can I instruct TypeScript to recognize promise
as my.IRequestPromise
instead of ng.IPromise
?