@@ -24,42 +24,45 @@ interface Promise<T> {
2424 * @param onrejected The callback to execute when the Promise is rejected.
2525 * @returns A Promise for the completion of which ever callback is executed.
2626 */
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 > ;
2828
2929 /**
3030 * Attaches callbacks for the resolution and/or rejection of the Promise.
3131 * @param onfulfilled The callback to execute when the Promise is resolved.
3232 * @param onrejected The callback to execute when the Promise is rejected.
3333 * @returns A Promise for the completion of which ever callback is executed.
3434 */
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 > ;
3636
3737 /**
3838 * Attaches callbacks for the resolution and/or rejection of the Promise.
3939 * @param onfulfilled The callback to execute when the Promise is resolved.
40+ * @param onrejected The callback to execute when the Promise is rejected.
4041 * @returns A Promise for the completion of which ever callback is executed.
4142 */
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 > ;
4344
4445 /**
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.
4750 */
48- then ( ) : Promise < T > ;
51+ then < TResult1 , TResult2 > ( onfulfilled : ( value : T ) => TResult1 | PromiseLike < TResult1 > , onrejected : ( reason : any ) => TResult2 | PromiseLike < TResult2 > ) : Promise < TResult1 | TResult2 > ;
4952
5053 /**
5154 * Attaches a callback for only the rejection of the Promise.
5255 * @param onrejected The callback to execute when the Promise is rejected.
5356 * @returns A Promise for the completion of the callback.
5457 */
55- catch < TResult > ( onrejected : ( reason : any ) => TResult | PromiseLike < TResult > ) : Promise < T | TResult > ;
58+ catch ( onrejected ? : ( ( reason : any ) => T | PromiseLike < T > ) | undefined | null ) : Promise < T > ;
5659
5760 /**
5861 * Attaches a callback for only the rejection of the Promise.
5962 * @param onrejected The callback to execute when the Promise is rejected.
6063 * @returns A Promise for the completion of the callback.
6164 */
62- catch ( onrejected : ( reason : any ) => T | PromiseLike < T > ) : Promise < T > ;
65+ catch < TResult > ( onrejected : ( reason : any ) => TResult | PromiseLike < TResult > ) : Promise < T | TResult > ;
6366}
6467
6568interface PromiseConstructor {
@@ -156,6 +159,86 @@ interface PromiseConstructor {
156159 */
157160 all < T > ( values : ( T | PromiseLike < T > ) [ ] ) : Promise < T [ ] > ;
158161
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+
159242 /**
160243 * Creates a new rejected promise for the provided reason.
161244 * @param reason The reason the promise was rejected.
0 commit comments