From 8c92375cfd13a3f382d151954cc86ff1ddc1d092 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Wed, 12 Jul 2017 20:07:43 -0400 Subject: [PATCH] [jquery] Fix PromiseLike compatibility for Promise3, Promise2, and jqXHR. --- types/jquery/index.d.ts | 3 +++ types/jquery/jquery-tests.ts | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 747abe207c..4ebb4692f5 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -6674,6 +6674,9 @@ declare namespace JQuery { progressFilter?: null): Promise3; + // PromiseLike compatibility + then(onfulfilled?: ((value: TR) => TResult1 | PromiseLike) | undefined | null, + onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; /** * Add handlers to be called when the Deferred object is rejected. diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index b7bf78156c..01cc4a345e 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -7138,6 +7138,13 @@ function Promise3() { return $.ajax('/echo/json'); }); } + + // As argument to PromiseLike parameter + { + Promise.resolve(p).then(a => { + a; // $ExpectType string + }); + } } function Promise2(p: JQuery.Promise2) {