JQuery: make JQueryXHR.then method generic.

This commit is contained in:
Alexey Vagarenko
2016-03-04 03:36:36 +05:00
parent ba4c4fc6c9
commit 661fc86966
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -199,6 +199,11 @@ function test_ajax() {
console.log(jqXHR, textStatus, errorThrown);
});
// generic then method
var p: JQueryPromise<number> = $.ajax({ url: "test.js" })
.then(() => "Hello")
.then((x) => x.length);
// jqXHR object
var jqXHR = $.ajax({
url: "test.js"
+1 -1
View File
@@ -180,7 +180,7 @@ interface JQueryXHR extends XMLHttpRequest, JQueryPromise<any> {
/**
* Incorporates the functionality of the .done() and .fail() methods, allowing (as of jQuery 1.8) the underlying Promise to be manipulated. Refer to deferred.then() for implementation details.
*/
then(doneCallback: (data: any, textStatus: string, jqXHR: JQueryXHR) => void, failCallback?: (jqXHR: JQueryXHR, textStatus: string, errorThrown: any) => void): JQueryPromise<any>;
then<R>(doneCallback: (data: any, textStatus: string, jqXHR: JQueryXHR) => R, failCallback?: (jqXHR: JQueryXHR, textStatus: string, errorThrown: any) => void): JQueryPromise<R>;
/**
* Property containing the parsed response if the response Content-Type is json
*/