@@ -24,42 +24,45 @@ interface Promise<T> {
24
24
* @param onrejected The callback to execute when the Promise is rejected.
25
25
* @returns A Promise for the completion of which ever callback is executed.
26
26
*/
27
- then < TResult1 , TResult2 > ( onfulfilled : ( value : T ) => TResult1 | PromiseLike < TResult1 > , onrejected : ( reason : any ) => TResult2 | PromiseLike < TResult2 > ) : Promise < TResult1 | TResult2 > ;
27
+ then ( onfulfilled ? : ( ( value : T ) => T | PromiseLike < T > ) | undefined | null , onrejected ? : ( ( reason : any ) => T | PromiseLike < T > ) | undefined | null ) : Promise < T > ;
28
28
29
29
/**
30
30
* Attaches callbacks for the resolution and/or rejection of the Promise.
31
31
* @param onfulfilled The callback to execute when the Promise is resolved.
32
32
* @param onrejected The callback to execute when the Promise is rejected.
33
33
* @returns A Promise for the completion of which ever callback is executed.
34
34
*/
35
- then < TResult > ( onfulfilled : ( value : T ) => TResult | PromiseLike < TResult > , onrejected : ( reason : any ) => TResult | PromiseLike < TResult > ) : Promise < TResult > ;
35
+ then < TResult > ( onfulfilled : ( ( value : T ) => T | PromiseLike < T > ) | undefined | null , onrejected : ( reason : any ) => TResult | PromiseLike < TResult > ) : Promise < T | TResult > ;
36
36
37
37
/**
38
38
* Attaches callbacks for the resolution and/or rejection of the Promise.
39
39
* @param onfulfilled The callback to execute when the Promise is resolved.
40
+ * @param onrejected The callback to execute when the Promise is rejected.
40
41
* @returns A Promise for the completion of which ever callback is executed.
41
42
*/
42
- then < TResult > ( onfulfilled : ( value : T ) => TResult | PromiseLike < TResult > ) : Promise < TResult > ;
43
+ then < TResult > ( onfulfilled : ( value : T ) => TResult | PromiseLike < TResult > , onrejected ?: ( ( reason : any ) => TResult | PromiseLike < TResult > ) | undefined | null ) : Promise < TResult > ;
43
44
44
45
/**
45
- * Creates a new Promise with the same internal state of this Promise.
46
- * @returns A Promise.
46
+ * Attaches callbacks for the resolution and/or rejection of the Promise.
47
+ * @param onfulfilled The callback to execute when the Promise is resolved.
48
+ * @param onrejected The callback to execute when the Promise is rejected.
49
+ * @returns A Promise for the completion of which ever callback is executed.
47
50
*/
48
- then ( ) : Promise < T > ;
51
+ then < TResult1 , TResult2 > ( onfulfilled : ( value : T ) => TResult1 | PromiseLike < TResult1 > , onrejected : ( reason : any ) => TResult2 | PromiseLike < TResult2 > ) : Promise < TResult1 | TResult2 > ;
49
52
50
53
/**
51
54
* Attaches a callback for only the rejection of the Promise.
52
55
* @param onrejected The callback to execute when the Promise is rejected.
53
56
* @returns A Promise for the completion of the callback.
54
57
*/
55
- catch < TResult > ( onrejected : ( reason : any ) => TResult | PromiseLike < TResult > ) : Promise < T | TResult > ;
58
+ catch ( onrejected ? : ( ( reason : any ) => T | PromiseLike < T > ) | undefined | null ) : Promise < T > ;
56
59
57
60
/**
58
61
* Attaches a callback for only the rejection of the Promise.
59
62
* @param onrejected The callback to execute when the Promise is rejected.
60
63
* @returns A Promise for the completion of the callback.
61
64
*/
62
- catch ( onrejected : ( reason : any ) => T | PromiseLike < T > ) : Promise < T > ;
65
+ catch < TResult > ( onrejected : ( reason : any ) => TResult | PromiseLike < TResult > ) : Promise < T | TResult > ;
63
66
}
64
67
65
68
interface PromiseConstructor {
@@ -156,6 +159,86 @@ interface PromiseConstructor {
156
159
*/
157
160
all < T > ( values : ( T | PromiseLike < T > ) [ ] ) : Promise < T [ ] > ;
158
161
162
+ /**
163
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
164
+ * or rejected.
165
+ * @param values An array of Promises.
166
+ * @returns A new Promise.
167
+ */
168
+ race < 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 > ;
169
+
170
+ /**
171
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
172
+ * or rejected.
173
+ * @param values An array of Promises.
174
+ * @returns A new Promise.
175
+ */
176
+ race < 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 > ;
177
+
178
+ /**
179
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
180
+ * or rejected.
181
+ * @param values An array of Promises.
182
+ * @returns A new Promise.
183
+ */
184
+ race < 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 > ;
185
+
186
+ /**
187
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
188
+ * or rejected.
189
+ * @param values An array of Promises.
190
+ * @returns A new Promise.
191
+ */
192
+ race < 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 > ;
193
+
194
+ /**
195
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
196
+ * or rejected.
197
+ * @param values An array of Promises.
198
+ * @returns A new Promise.
199
+ */
200
+ race < 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 > ;
201
+
202
+ /**
203
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
204
+ * or rejected.
205
+ * @param values An array of Promises.
206
+ * @returns A new Promise.
207
+ */
208
+ race < 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 > ;
209
+
210
+ /**
211
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
212
+ * or rejected.
213
+ * @param values An array of Promises.
214
+ * @returns A new Promise.
215
+ */
216
+ race < T1 , T2 , T3 , T4 > ( values : [ T1 | PromiseLike < T1 > , T2 | PromiseLike < T2 > , T3 | PromiseLike < T3 > , T4 | PromiseLike < T4 > ] ) : Promise < T1 | T2 | T3 | T4 > ;
217
+
218
+ /**
219
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
220
+ * or rejected.
221
+ * @param values An array of Promises.
222
+ * @returns A new Promise.
223
+ */
224
+ race < T1 , T2 , T3 > ( values : [ T1 | PromiseLike < T1 > , T2 | PromiseLike < T2 > , T3 | PromiseLike < T3 > ] ) : Promise < T1 | T2 | T3 > ;
225
+
226
+ /**
227
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
228
+ * or rejected.
229
+ * @param values An array of Promises.
230
+ * @returns A new Promise.
231
+ */
232
+ race < T1 , T2 > ( values : [ T1 | PromiseLike < T1 > , T2 | PromiseLike < T2 > ] ) : Promise < T1 | T2 > ;
233
+
234
+ /**
235
+ * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
236
+ * or rejected.
237
+ * @param values An array of Promises.
238
+ * @returns A new Promise.
239
+ */
240
+ race < T > ( values : ( T | PromiseLike < T > ) [ ] ) : Promise < T > ;
241
+
159
242
/**
160
243
* Creates a new rejected promise for the provided reason.
161
244
* @param reason The reason the promise was rejected.
0 commit comments