diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index ccc343a3c2..28e02b0d98 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -199,6 +199,11 @@ function test_ajax() { console.log(jqXHR, textStatus, errorThrown); }); + // generic then method + var p: JQueryPromise = $.ajax({ url: "test.js" }) + .then(() => "Hello") + .then((x) => x.length); + // jqXHR object var jqXHR = $.ajax({ url: "test.js" diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 6c43e6cf93..0a98e5289d 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -180,7 +180,7 @@ interface JQueryXHR extends XMLHttpRequest, JQueryPromise { /** * 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; + then(doneCallback: (data: any, textStatus: string, jqXHR: JQueryXHR) => R, failCallback?: (jqXHR: JQueryXHR, textStatus: string, errorThrown: any) => void): JQueryPromise; /** * Property containing the parsed response if the response Content-Type is json */