|
3 | 3 | */
|
4 | 4 | interface Promise<T> {
|
5 | 5 | /**
|
6 |
| - * Attaches callbacks for the resolution and/or rejection of the Promise. |
7 |
| - * @param onfulfilled The callback to execute when the Promise is resolved. |
8 |
| - * @param onrejected The callback to execute when the Promise is rejected. |
9 |
| - * @returns A Promise for the completion of which ever callback is executed. |
10 |
| - */ |
11 |
| - then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; |
12 |
| - then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>; |
| 6 | + * Attaches callbacks for the resolution and/or rejection of the Promise. |
| 7 | + * @param onfulfilled The callback to execute when the Promise is resolved. |
| 8 | + * @param onrejected The callback to execute when the Promise is rejected. |
| 9 | + * @returns A Promise for the completion of which ever callback is executed. |
| 10 | + */ |
| 11 | + then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; |
| 12 | + |
| 13 | + /** |
| 14 | + * Attaches callbacks for the resolution and/or rejection of the Promise. |
| 15 | + * @param onfulfilled The callback to execute when the Promise is resolved. |
| 16 | + * @param onrejected The callback to execute when the Promise is rejected. |
| 17 | + * @returns A Promise for the completion of which ever callback is executed. |
| 18 | + */ |
| 19 | + then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; |
| 20 | + |
| 21 | + /** |
| 22 | + * Attaches callbacks for the resolution and/or rejection of the Promise. |
| 23 | + * @param onfulfilled The callback to execute when the Promise is resolved. |
| 24 | + * @returns A Promise for the completion of which ever callback is executed. |
| 25 | + */ |
| 26 | + then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>): Promise<TResult>; |
| 27 | + |
| 28 | + /** |
| 29 | + * Creates a new Promise with the same internal state of this Promise. |
| 30 | + * @returns A Promise. |
| 31 | + */ |
| 32 | + then(): Promise<T>; |
13 | 33 |
|
14 | 34 | /**
|
15 | 35 | * Attaches a callback for only the rejection of the Promise.
|
16 | 36 | * @param onrejected The callback to execute when the Promise is rejected.
|
17 | 37 | * @returns A Promise for the completion of the callback.
|
18 | 38 | */
|
19 |
| - catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>; |
20 |
| - catch(onrejected?: (reason: any) => void): Promise<T>; |
| 39 | + catch<TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>; |
| 40 | + |
| 41 | + /** |
| 42 | + * Attaches a callback for only the rejection of the Promise. |
| 43 | + * @param onrejected The callback to execute when the Promise is rejected. |
| 44 | + * @returns A Promise for the completion of the callback. |
| 45 | + */ |
| 46 | + catch(onrejected: (reason: any) => T | PromiseLike<T>): Promise<T>; |
21 | 47 | }
|
22 | 48 |
|
23 | 49 | interface PromiseConstructor {
|
24 |
| - /** |
25 |
| - * A reference to the prototype. |
| 50 | + /** |
| 51 | + * A reference to the prototype. |
26 | 52 | */
|
27 | 53 | readonly prototype: Promise<any>;
|
28 | 54 |
|
29 | 55 | /**
|
30 | 56 | * Creates a new Promise.
|
31 |
| - * @param executor A callback used to initialize the promise. This callback is passed two arguments: |
32 |
| - * a resolve callback used resolve the promise with a value or the result of another promise, |
| 57 | + * @param executor A callback used to initialize the promise. This callback is passed two arguments: |
| 58 | + * a resolve callback used resolve the promise with a value or the result of another promise, |
33 | 59 | * and a reject callback used to reject the promise with a provided reason or error.
|
34 | 60 | */
|
35 | 61 | new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
|
36 | 62 |
|
37 | 63 | /**
|
38 |
| - * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 64 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
39 | 65 | * resolve, or rejected when any Promise is rejected.
|
40 | 66 | * @param values An array of Promises.
|
41 | 67 | * @returns A new Promise.
|
42 | 68 | */
|
43 | 69 | all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
|
| 70 | + |
| 71 | + /** |
| 72 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 73 | + * resolve, or rejected when any Promise is rejected. |
| 74 | + * @param values An array of Promises. |
| 75 | + * @returns A new Promise. |
| 76 | + */ |
44 | 77 | all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
|
| 78 | + |
| 79 | + /** |
| 80 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 81 | + * resolve, or rejected when any Promise is rejected. |
| 82 | + * @param values An array of Promises. |
| 83 | + * @returns A new Promise. |
| 84 | + */ |
45 | 85 | all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
|
| 86 | + |
| 87 | + /** |
| 88 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 89 | + * resolve, or rejected when any Promise is rejected. |
| 90 | + * @param values An array of Promises. |
| 91 | + * @returns A new Promise. |
| 92 | + */ |
46 | 93 | all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
|
| 94 | + |
| 95 | + /** |
| 96 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 97 | + * resolve, or rejected when any Promise is rejected. |
| 98 | + * @param values An array of Promises. |
| 99 | + * @returns A new Promise. |
| 100 | + */ |
47 | 101 | all<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
|
| 102 | + |
| 103 | + /** |
| 104 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 105 | + * resolve, or rejected when any Promise is rejected. |
| 106 | + * @param values An array of Promises. |
| 107 | + * @returns A new Promise. |
| 108 | + */ |
48 | 109 | all<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
| 110 | + |
| 111 | + /** |
| 112 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 113 | + * resolve, or rejected when any Promise is rejected. |
| 114 | + * @param values An array of Promises. |
| 115 | + * @returns A new Promise. |
| 116 | + */ |
49 | 117 | all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
|
| 118 | + |
| 119 | + /** |
| 120 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 121 | + * resolve, or rejected when any Promise is rejected. |
| 122 | + * @param values An array of Promises. |
| 123 | + * @returns A new Promise. |
| 124 | + */ |
50 | 125 | all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
|
| 126 | + |
| 127 | + /** |
| 128 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 129 | + * resolve, or rejected when any Promise is rejected. |
| 130 | + * @param values An array of Promises. |
| 131 | + * @returns A new Promise. |
| 132 | + */ |
51 | 133 | all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
|
52 | 134 |
|
| 135 | + /** |
| 136 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 137 | + * resolve, or rejected when any Promise is rejected. |
| 138 | + * @param values An array of Promises. |
| 139 | + * @returns A new Promise. |
| 140 | + */ |
| 141 | + all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>; |
| 142 | + |
53 | 143 | /**
|
54 | 144 | * Creates a new rejected promise for the provided reason.
|
55 | 145 | * @param reason The reason the promise was rejected.
|
56 | 146 | * @returns A new rejected Promise.
|
57 | 147 | */
|
58 |
| - reject(reason: any): Promise<void>; |
| 148 | + reject(reason: any): Promise<never>; |
59 | 149 |
|
60 | 150 | /**
|
61 | 151 | * Creates a new rejected promise for the provided reason.
|
|
0 commit comments