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