From a6134ee5a1e6db498f570e98bb77aeaf8fa02cbc Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Wed, 28 Jun 2017 13:28:42 -0400 Subject: [PATCH] [jquery] Remove support for multiple multi-argument Promises from when(). --- types/jquery/index.d.ts | 42 ------- types/jquery/jquery-tests.ts | 205 +++++++++++++++++------------------ 2 files changed, 102 insertions(+), 145 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index ab44375843..834ee4c70d 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -3267,30 +3267,6 @@ interface JQueryStatic { * @since 1.12-2.2 */ uniqueSort(array: T[]): T[]; - /** - * Provides a way to execute callback functions based on zero or more Thenable objects, usually - * Deferred objects that represent asynchronous events. - * - * @see {@link https://api.jquery.com/jQuery.when/} - * @since 1.5 - */ - when - (deferredT: JQuery.Promise3 | - JQuery.Promise2, - deferredU: JQuery.Promise3 | - JQuery.Promise2, - deferredV: JQuery.Promise3 | - JQuery.Promise2): JQuery.Promise3<[TR1, TR2, TR3], [TJ1, TJ2, TJ3], never, - [UR1, UR2, UR3], [UJ1, UJ2, UJ3], never, - [VR1, VR2, VR3], [VJ1, VJ2, VJ3], never>; /** * Provides a way to execute callback functions based on zero or more Thenable objects, usually * Deferred objects that represent asynchronous events. @@ -3312,24 +3288,6 @@ interface JQueryStatic { * @see {@link https://api.jquery.com/jQuery.when/} * @since 1.5 */ - when - (deferredT: JQuery.Promise3 | - JQuery.Promise2, - deferredU: JQuery.Promise3 | - JQuery.Promise2): JQuery.Promise2<[TR1, TR2, TR3], [TJ1, TJ2, TJ3], never, - [UR1, UR2, UR3], [UJ1, UJ2, UJ3], never>; - /** - * Provides a way to execute callback functions based on zero or more Thenable objects, usually - * Deferred objects that represent asynchronous events. - * - * @see {@link https://api.jquery.com/jQuery.when/} - * @since 1.5 - */ when (deferredT: JQuery.Promise | JQuery.Thenable | TR1, diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 3e93fc84b8..325a288889 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -4463,60 +4463,60 @@ function JQueryStatic() { const u = $.ajax() as JQuery.jqXHR; const v = $.ajax() as JQuery.jqXHR; - // 3 parameters - { - const w = $.when(t, u, v); - - w.then((a, b, c) => { - a[0]; // $ExpectType string - a[1]; // $ExpectType SuccessTextStatus - a[2]; // $ExpectType jqXHR - b[0]; // $ExpectType number - b[1]; // $ExpectType SuccessTextStatus - b[2]; // $ExpectType jqXHR - c[0]; // $ExpectType boolean - c[1]; // $ExpectType SuccessTextStatus - c[2]; // $ExpectType jqXHR - }, (a, b, c) => { - a[0]; // $ExpectType jqXHR - a[1]; // $ExpectType ErrorTextStatus - a[2]; // $ExpectType string - b[0]; // $ExpectType jqXHR - b[1]; // $ExpectType ErrorTextStatus - b[2]; // $ExpectType string - c[0]; // $ExpectType jqXHR - c[1]; // $ExpectType ErrorTextStatus - c[2]; // $ExpectType string - }, (a, b, c) => { - a; // $ExpectType never - b; // $ExpectType never - c; // $ExpectType never - }); - } - - // 2 parameters - { - const w = $.when(t, u); - - w.then((a, b) => { - a[0]; // $ExpectType string - a[1]; // $ExpectType SuccessTextStatus - a[2]; // $ExpectType jqXHR - b[0]; // $ExpectType number - b[1]; // $ExpectType SuccessTextStatus - b[2]; // $ExpectType jqXHR - }, (a, b) => { - a[0]; // $ExpectType jqXHR - a[1]; // $ExpectType ErrorTextStatus - a[2]; // $ExpectType string - b[0]; // $ExpectType jqXHR - b[1]; // $ExpectType ErrorTextStatus - b[2]; // $ExpectType string - }, (a, b) => { - a; // $ExpectType never - b; // $ExpectType never - }); - } + // // 3 parameters + // { + // const w = $.when(t, u, v); + // + // w.then((a, b, c) => { + // a[0]; // $ExpectType string + // a[1]; // $ExpectType SuccessTextStatus + // a[2]; // $ExpectType jqXHR + // b[0]; // $ExpectType number + // b[1]; // $ExpectType SuccessTextStatus + // b[2]; // $ExpectType jqXHR + // c[0]; // $ExpectType boolean + // c[1]; // $ExpectType SuccessTextStatus + // c[2]; // $ExpectType jqXHR + // }, (a, b, c) => { + // a[0]; // $ExpectType jqXHR + // a[1]; // $ExpectType ErrorTextStatus + // a[2]; // $ExpectType string + // b[0]; // $ExpectType jqXHR + // b[1]; // $ExpectType ErrorTextStatus + // b[2]; // $ExpectType string + // c[0]; // $ExpectType jqXHR + // c[1]; // $ExpectType ErrorTextStatus + // c[2]; // $ExpectType string + // }, (a, b, c) => { + // a; // $ExpectType never + // b; // $ExpectType never + // c; // $ExpectType never + // }); + // } + // + // // 2 parameters + // { + // const w = $.when(t, u); + // + // w.then((a, b) => { + // a[0]; // $ExpectType string + // a[1]; // $ExpectType SuccessTextStatus + // a[2]; // $ExpectType jqXHR + // b[0]; // $ExpectType number + // b[1]; // $ExpectType SuccessTextStatus + // b[2]; // $ExpectType jqXHR + // }, (a, b) => { + // a[0]; // $ExpectType jqXHR + // a[1]; // $ExpectType ErrorTextStatus + // a[2]; // $ExpectType string + // b[0]; // $ExpectType jqXHR + // b[1]; // $ExpectType ErrorTextStatus + // b[2]; // $ExpectType string + // }, (a, b) => { + // a; // $ExpectType never + // b; // $ExpectType never + // }); + // } // 1 parameter { @@ -4543,50 +4543,50 @@ function JQueryStatic() { const u: JQuery.Promise2 = {} as any; const v: JQuery.Promise2 = {} as any; - // 3 parameters - { - const w = $.when(t, u, v); - - w.then((a, b, c) => { - a[0]; // $ExpectType string - a[1]; // $ExpectType boolean - b[0]; // $ExpectType string - b[1]; // $ExpectType boolean - c[0]; // $ExpectType string - c[1]; // $ExpectType boolean - }, (a, b, c) => { - a[0]; // $ExpectType Error - a[1]; // $ExpectType any - b[0]; // $ExpectType Error - b[1]; // $ExpectType any - c[0]; // $ExpectType Error - c[1]; // $ExpectType any - }, (a, b, c) => { - a; // $ExpectType never - b; // $ExpectType never - c; // $ExpectType never - }); - } - - // 2 parameters - { - const w = $.when(t, u); - - w.then((a, b) => { - a[0]; // $ExpectType string - a[1]; // $ExpectType boolean - b[0]; // $ExpectType string - b[1]; // $ExpectType boolean - }, (a, b) => { - a[0]; // $ExpectType Error - a[1]; // $ExpectType any - b[0]; // $ExpectType Error - b[1]; // $ExpectType any - }, (a, b) => { - a; // $ExpectType never - b; // $ExpectType never - }); - } + // // 3 parameters + // { + // const w = $.when(t, u, v); + // + // w.then((a, b, c) => { + // a[0]; // $ExpectType string + // a[1]; // $ExpectType boolean + // b[0]; // $ExpectType string + // b[1]; // $ExpectType boolean + // c[0]; // $ExpectType string + // c[1]; // $ExpectType boolean + // }, (a, b, c) => { + // a[0]; // $ExpectType Error + // a[1]; // $ExpectType any + // b[0]; // $ExpectType Error + // b[1]; // $ExpectType any + // c[0]; // $ExpectType Error + // c[1]; // $ExpectType any + // }, (a, b, c) => { + // a; // $ExpectType never + // b; // $ExpectType never + // c; // $ExpectType never + // }); + // } + // + // // 2 parameters + // { + // const w = $.when(t, u); + // + // w.then((a, b) => { + // a[0]; // $ExpectType string + // a[1]; // $ExpectType boolean + // b[0]; // $ExpectType string + // b[1]; // $ExpectType boolean + // }, (a, b) => { + // a[0]; // $ExpectType Error + // a[1]; // $ExpectType any + // b[0]; // $ExpectType Error + // b[1]; // $ExpectType any + // }, (a, b) => { + // a; // $ExpectType never + // b; // $ExpectType never + // }); + // } // 1 parameter { @@ -4742,8 +4742,7 @@ function JQueryStatic() { $.when().then(() => { return first(); }).then((value) => { - // $ExpectType string - value; + value; // $ExpectType string }); } @@ -4755,9 +4754,9 @@ function JQueryStatic() { class AsyncRunner { Run(): void { - const task1: JQuery.Promise = {} as any; - const task2: JQuery.Promise = this.runTask2(); - const task3: JQuery.Promise = this.runTask3(); + const task1 = this.runTask1(); + const task2 = this.runTask2(); + const task3 = this.runTask3(); $.when(task1, task2, task3) .then((r1, r2, r3) => {