mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-08 17:19:27 +08:00
[jquery] Remove support for multiple multi-argument Promises from when().
This commit is contained in:
42
types/jquery/index.d.ts
vendored
42
types/jquery/index.d.ts
vendored
@@ -3267,30 +3267,6 @@ interface JQueryStatic<TElement extends Node = HTMLElement> {
|
||||
* @since 1.12-2.2
|
||||
*/
|
||||
uniqueSort<T extends Element>(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<TR1, TJ1,
|
||||
UR1, UJ1,
|
||||
VR1, VJ1,
|
||||
TR2, TJ2,
|
||||
UR2, UJ2,
|
||||
VR2, VJ2,
|
||||
TR3 = never, TJ3 = never,
|
||||
UR3 = never, UJ3 = never,
|
||||
VR3 = never, VJ3 = never>
|
||||
(deferredT: JQuery.Promise3<TR1, TJ1, any, TR2, TJ2, any, TR3, TJ3, any> |
|
||||
JQuery.Promise2<TR1, TJ1, any, TR2, TJ2, any>,
|
||||
deferredU: JQuery.Promise3<UR1, UJ1, any, UR2, UJ2, any, UR3, UJ3, any> |
|
||||
JQuery.Promise2<UR1, UJ1, any, UR2, UJ2, any>,
|
||||
deferredV: JQuery.Promise3<VR1, VJ1, any, VR2, VJ2, any, VR3, VJ3, any> |
|
||||
JQuery.Promise2<VR1, VJ1, any, VR2, VJ2, any>): 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<TElement extends Node = HTMLElement> {
|
||||
* @see {@link https://api.jquery.com/jQuery.when/}
|
||||
* @since 1.5
|
||||
*/
|
||||
when<TR1, TJ1,
|
||||
UR1, UJ1,
|
||||
TR2, TJ2,
|
||||
UR2, UJ2,
|
||||
TR3 = never, TJ3 = never,
|
||||
UR3 = never, UJ3 = never>
|
||||
(deferredT: JQuery.Promise3<TR1, TJ1, any, TR2, TJ2, any, TR3, TJ3, any> |
|
||||
JQuery.Promise2<TR1, TJ1, any, TR2, TJ2, any>,
|
||||
deferredU: JQuery.Promise3<UR1, UJ1, any, UR2, UJ2, any, UR3, UJ3, any> |
|
||||
JQuery.Promise2<UR1, UJ1, any, UR2, UJ2, any>): 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<TR1, UR1,
|
||||
TJ1 = any, UJ1 = any>
|
||||
(deferredT: JQuery.Promise<TR1, TJ1, any> | JQuery.Thenable<TR1> | TR1,
|
||||
|
||||
@@ -4463,60 +4463,60 @@ function JQueryStatic() {
|
||||
const u = $.ajax() as JQuery.jqXHR<number>;
|
||||
const v = $.ajax() as JQuery.jqXHR<boolean>;
|
||||
|
||||
// 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<string>
|
||||
b[0]; // $ExpectType number
|
||||
b[1]; // $ExpectType SuccessTextStatus
|
||||
b[2]; // $ExpectType jqXHR<number>
|
||||
c[0]; // $ExpectType boolean
|
||||
c[1]; // $ExpectType SuccessTextStatus
|
||||
c[2]; // $ExpectType jqXHR<boolean>
|
||||
}, (a, b, c) => {
|
||||
a[0]; // $ExpectType jqXHR<string>
|
||||
a[1]; // $ExpectType ErrorTextStatus
|
||||
a[2]; // $ExpectType string
|
||||
b[0]; // $ExpectType jqXHR<number>
|
||||
b[1]; // $ExpectType ErrorTextStatus
|
||||
b[2]; // $ExpectType string
|
||||
c[0]; // $ExpectType jqXHR<boolean>
|
||||
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<string>
|
||||
b[0]; // $ExpectType number
|
||||
b[1]; // $ExpectType SuccessTextStatus
|
||||
b[2]; // $ExpectType jqXHR<number>
|
||||
}, (a, b) => {
|
||||
a[0]; // $ExpectType jqXHR<string>
|
||||
a[1]; // $ExpectType ErrorTextStatus
|
||||
a[2]; // $ExpectType string
|
||||
b[0]; // $ExpectType jqXHR<number>
|
||||
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<string>
|
||||
// b[0]; // $ExpectType number
|
||||
// b[1]; // $ExpectType SuccessTextStatus
|
||||
// b[2]; // $ExpectType jqXHR<number>
|
||||
// c[0]; // $ExpectType boolean
|
||||
// c[1]; // $ExpectType SuccessTextStatus
|
||||
// c[2]; // $ExpectType jqXHR<boolean>
|
||||
// }, (a, b, c) => {
|
||||
// a[0]; // $ExpectType jqXHR<string>
|
||||
// a[1]; // $ExpectType ErrorTextStatus
|
||||
// a[2]; // $ExpectType string
|
||||
// b[0]; // $ExpectType jqXHR<number>
|
||||
// b[1]; // $ExpectType ErrorTextStatus
|
||||
// b[2]; // $ExpectType string
|
||||
// c[0]; // $ExpectType jqXHR<boolean>
|
||||
// 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<string>
|
||||
// b[0]; // $ExpectType number
|
||||
// b[1]; // $ExpectType SuccessTextStatus
|
||||
// b[2]; // $ExpectType jqXHR<number>
|
||||
// }, (a, b) => {
|
||||
// a[0]; // $ExpectType jqXHR<string>
|
||||
// a[1]; // $ExpectType ErrorTextStatus
|
||||
// a[2]; // $ExpectType string
|
||||
// b[0]; // $ExpectType jqXHR<number>
|
||||
// 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<string, Error, number, boolean, any, any> = {} as any;
|
||||
const v: JQuery.Promise2<string, Error, number, boolean, any, any> = {} 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<One, any, any> = {} as any;
|
||||
const task2: JQuery.Promise<Two, any, any> = this.runTask2();
|
||||
const task3: JQuery.Promise<Three, any, any> = this.runTask3();
|
||||
const task1 = this.runTask1();
|
||||
const task2 = this.runTask2();
|
||||
const task3 = this.runTask3();
|
||||
|
||||
$.when(task1, task2, task3)
|
||||
.then((r1, r2, r3) => {
|
||||
|
||||
Reference in New Issue
Block a user