@@ -207,9 +207,10 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
207
207
}
208
208
}
209
209
210
- function scheduleResolveOrReject < R , U > (
211
- promise : ZoneAwarePromise < any > , zone : AmbientZone , chainPromise : ZoneAwarePromise < any > ,
212
- onFulfilled ?: ( value : R ) => U , onRejected ?: ( error : any ) => U ) : void {
210
+ function scheduleResolveOrReject < R , U1 , U2 > (
211
+ promise : ZoneAwarePromise < any > , zone : AmbientZone ,
212
+ chainPromise : ZoneAwarePromise < any > , onFulfilled ?: ( value : R ) => U1 ,
213
+ onRejected ?: ( error : any ) => U2 ) : void {
213
214
clearRejectedNoCatch ( promise ) ;
214
215
const delegate = ( promise as any ) [ symbolState ] ?
215
216
( typeof onFulfilled === FUNCTION ) ? onFulfilled : forwardResolution :
@@ -265,7 +266,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
265
266
static all < R > ( values : any ) : Promise < R > {
266
267
let resolve : ( v : any ) => void ;
267
268
let reject : ( v : any ) => void ;
268
- let promise = new this ( ( res , rej ) => {
269
+ let promise = new this < R > ( ( res , rej ) => {
269
270
resolve = res ;
270
271
reject = rej ;
271
272
} ) ;
@@ -306,10 +307,13 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
306
307
}
307
308
}
308
309
309
- then < R , U > (
310
- onFulfilled ?: ( value : R ) => U | PromiseLike < U > ,
311
- onRejected ?: ( error : any ) => U | PromiseLike < U > ) : Promise < R > {
312
- const chainPromise : Promise < R > = new ( this . constructor as typeof ZoneAwarePromise ) ( null ) ;
310
+ then < TResult1 = R , TResult2 = never > (
311
+ onFulfilled ?: ( ( value : R ) => TResult1 | PromiseLike < TResult1 > ) |
312
+ undefined | null ,
313
+ onRejected ?: ( ( reason : any ) => TResult2 | PromiseLike < TResult2 > ) |
314
+ undefined | null ) : Promise < TResult1 | TResult2 > {
315
+ const chainPromise : Promise < TResult1 | TResult2 > =
316
+ new ( this . constructor as typeof ZoneAwarePromise ) ( null ) ;
313
317
const zone = Zone . current ;
314
318
if ( ( this as any ) [ symbolState ] == UNRESOLVED ) {
315
319
( < any [ ] > ( this as any ) [ symbolValue ] ) . push ( zone , chainPromise , onFulfilled , onRejected ) ;
@@ -319,7 +323,9 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
319
323
return chainPromise ;
320
324
}
321
325
322
- catch < U > ( onRejected ?: ( error : any ) => U | PromiseLike < U > ) : Promise < R > {
326
+ catch < TResult = never > (
327
+ onRejected ?: ( ( reason : any ) => TResult | PromiseLike < TResult > ) |
328
+ undefined | null ) : Promise < R | TResult > {
323
329
return this . then ( null , onRejected ) ;
324
330
}
325
331
}
0 commit comments