@@ -19,59 +19,149 @@ and limitations under the License.
1919 */
2020interface Promise < T > {
2121 /**
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- * @param onrejected The callback to execute when the Promise is rejected.
25- * @returns A Promise for the completion of which ever callback is executed.
26- */
27- then < TResult > ( onfulfilled ?: ( value : T ) => TResult | PromiseLike < TResult > , onrejected ?: ( reason : any ) => TResult | PromiseLike < TResult > ) : Promise < TResult > ;
28- then < TResult > ( onfulfilled ?: ( value : T ) => TResult | PromiseLike < TResult > , onrejected ?: ( reason : any ) => void ) : Promise < TResult > ;
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+ * @param onrejected The callback to execute when the Promise is rejected.
25+ * @returns A Promise for the completion of which ever callback is executed.
26+ */
27+ then < TResult1 , TResult2 > ( onfulfilled : ( value : T ) => TResult1 | PromiseLike < TResult1 > , onrejected : ( reason : any ) => TResult2 | PromiseLike < TResult2 > ) : Promise < TResult1 | TResult2 > ;
28+
29+ /**
30+ * Attaches callbacks for the resolution and/or rejection of the Promise.
31+ * @param onfulfilled The callback to execute when the Promise is resolved.
32+ * @param onrejected The callback to execute when the Promise is rejected.
33+ * @returns A Promise for the completion of which ever callback is executed.
34+ */
35+ then < TResult > ( onfulfilled : ( value : T ) => TResult | PromiseLike < TResult > , onrejected : ( reason : any ) => TResult | PromiseLike < TResult > ) : Promise < TResult > ;
36+
37+ /**
38+ * Attaches callbacks for the resolution and/or rejection of the Promise.
39+ * @param onfulfilled The callback to execute when the Promise is resolved.
40+ * @returns A Promise for the completion of which ever callback is executed.
41+ */
42+ then < TResult > ( onfulfilled : ( value : T ) => TResult | PromiseLike < TResult > ) : Promise < TResult > ;
43+
44+ /**
45+ * Creates a new Promise with the same internal state of this Promise.
46+ * @returns A Promise.
47+ */
48+ then ( ) : Promise < T > ;
2949
3050 /**
3151 * Attaches a callback for only the rejection of the Promise.
3252 * @param onrejected The callback to execute when the Promise is rejected.
3353 * @returns A Promise for the completion of the callback.
3454 */
35- catch ( onrejected ?: ( reason : any ) => T | PromiseLike < T > ) : Promise < T > ;
36- catch ( onrejected ?: ( reason : any ) => void ) : Promise < T > ;
55+ catch < TResult > ( onrejected : ( reason : any ) => TResult | PromiseLike < TResult > ) : Promise < T | TResult > ;
56+
57+ /**
58+ * Attaches a callback for only the rejection of the Promise.
59+ * @param onrejected The callback to execute when the Promise is rejected.
60+ * @returns A Promise for the completion of the callback.
61+ */
62+ catch ( onrejected : ( reason : any ) => T | PromiseLike < T > ) : Promise < T > ;
3763}
3864
3965interface PromiseConstructor {
40- /**
41- * A reference to the prototype.
66+ /**
67+ * A reference to the prototype.
4268 */
4369 readonly prototype : Promise < any > ;
4470
4571 /**
4672 * Creates a new Promise.
47- * @param executor A callback used to initialize the promise. This callback is passed two arguments:
48- * a resolve callback used resolve the promise with a value or the result of another promise,
73+ * @param executor A callback used to initialize the promise. This callback is passed two arguments:
74+ * a resolve callback used resolve the promise with a value or the result of another promise,
4975 * and a reject callback used to reject the promise with a provided reason or error.
5076 */
5177 new < T > ( executor : ( resolve : ( value ?: T | PromiseLike < T > ) => void , reject : ( reason ?: any ) => void ) => void ) : Promise < T > ;
5278
5379 /**
54- * Creates a Promise that is resolved with an array of results when all of the provided Promises
80+ * Creates a Promise that is resolved with an array of results when all of the provided Promises
5581 * resolve, or rejected when any Promise is rejected.
5682 * @param values An array of Promises.
5783 * @returns A new Promise.
5884 */
5985 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 ] > ;
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+ */
6093 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 ] > ;
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+ */
61101 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 ] > ;
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+ */
62109 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 ] > ;
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+ */
63117 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 ] > ;
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+ */
64125 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 ] > ;
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+ */
65133 all < T1 , T2 , T3 , T4 > ( values : [ T1 | PromiseLike < T1 > , T2 | PromiseLike < T2 > , T3 | PromiseLike < T3 > , T4 | PromiseLike < T4 > ] ) : Promise < [ T1 , T2 , T3 , T4 ] > ;
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+ */
66141 all < T1 , T2 , T3 > ( values : [ T1 | PromiseLike < T1 > , T2 | PromiseLike < T2 > , T3 | PromiseLike < T3 > ] ) : Promise < [ T1 , T2 , T3 ] > ;
142+
143+ /**
144+ * Creates a Promise that is resolved with an array of results when all of the provided Promises
145+ * resolve, or rejected when any Promise is rejected.
146+ * @param values An array of Promises.
147+ * @returns A new Promise.
148+ */
67149 all < T1 , T2 > ( values : [ T1 | PromiseLike < T1 > , T2 | PromiseLike < T2 > ] ) : Promise < [ T1 , T2 ] > ;
68150
151+ /**
152+ * Creates a Promise that is resolved with an array of results when all of the provided Promises
153+ * resolve, or rejected when any Promise is rejected.
154+ * @param values An array of Promises.
155+ * @returns A new Promise.
156+ */
157+ all < T > ( values : ( T | PromiseLike < T > ) [ ] ) : Promise < T [ ] > ;
158+
69159 /**
70160 * Creates a new rejected promise for the provided reason.
71161 * @param reason The reason the promise was rejected.
72162 * @returns A new rejected Promise.
73163 */
74- reject ( reason : any ) : Promise < void > ;
164+ reject ( reason : any ) : Promise < never > ;
75165
76166 /**
77167 * Creates a new rejected promise for the provided reason.
0 commit comments