From 661fc869669af796c6048483e999dce5732eed72 Mon Sep 17 00:00:00 2001 From: Alexey Vagarenko Date: Fri, 4 Mar 2016 03:36:36 +0500 Subject: [PATCH] JQuery: make JQueryXHR.then method generic. --- jquery/jquery-tests.ts | 5 +++++ jquery/jquery.d.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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 */