Merge pull request #8374 from vagarenko/master

JQuery: make JQueryXHR.then method generic.
This commit is contained in:
John Reilly
2016-03-04 04:55:34 +00:00
2 changed files with 6 additions and 1 deletions

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"

2
jquery/jquery.d.ts vendored
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
*/