@@ -46,7 +46,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
46
46
api . microtaskDrainDone = ( ) => {
47
47
while ( _uncaughtPromiseErrors . length ) {
48
48
while ( _uncaughtPromiseErrors . length ) {
49
- const uncaughtPromiseError : UncaughtPromiseError = _uncaughtPromiseErrors . shift ( ) ;
49
+ const uncaughtPromiseError : UncaughtPromiseError = _uncaughtPromiseErrors . shift ( ) ! ;
50
50
try {
51
51
uncaughtPromiseError . zone . runGuarded ( ( ) => {
52
52
throw uncaughtPromiseError ;
@@ -164,7 +164,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
164
164
( promise as any ) [ symbolValue ] = value ;
165
165
166
166
if ( ( promise as any ) [ symbolFinally ] === symbolFinally ) {
167
- // the promise is generated by Promise.prototype.finally
167
+ // the promise is generated by Promise.prototype.finally
168
168
if ( state === RESOLVED ) {
169
169
// the state is resolved, should ignore the value
170
170
// and use parent promise value
@@ -202,7 +202,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
202
202
error . rejection = value ;
203
203
error . promise = promise ;
204
204
error . zone = Zone . current ;
205
- error . task = Zone . currentTask ;
205
+ error . task = Zone . currentTask ! ;
206
206
_uncaughtPromiseErrors . push ( error ) ;
207
207
api . scheduleMicroTask ( ) ; // to make sure that it is running
208
208
}
@@ -239,7 +239,8 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
239
239
240
240
function scheduleResolveOrReject < R , U1 , U2 > (
241
241
promise : ZoneAwarePromise < any > , zone : AmbientZone , chainPromise : ZoneAwarePromise < any > ,
242
- onFulfilled ?: ( value : R ) => U1 , onRejected ?: ( error : any ) => U2 ) : void {
242
+ onFulfilled ?: ( ( value : R ) => U1 ) | null | undefined ,
243
+ onRejected ?: ( ( error : any ) => U2 ) | null | undefined ) : void {
243
244
clearRejectedNoCatch ( promise ) ;
244
245
const promiseState = ( promise as any ) [ symbolState ] ;
245
246
const delegate = promiseState ?
@@ -248,14 +249,19 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
248
249
zone . scheduleMicroTask ( source , ( ) => {
249
250
try {
250
251
const parentPromiseValue = ( promise as any ) [ symbolValue ] ;
251
- const isFinallyPromise = chainPromise && symbolFinally === ( chainPromise as any ) [ symbolFinally ] ;
252
+ const isFinallyPromise =
253
+ chainPromise && symbolFinally === ( chainPromise as any ) [ symbolFinally ] ;
252
254
if ( isFinallyPromise ) {
253
255
// if the promise is generated from finally call, keep parent promise's state and value
254
256
( chainPromise as any ) [ symbolParentPromiseValue ] = parentPromiseValue ;
255
257
( chainPromise as any ) [ symbolParentPromiseState ] = promiseState ;
256
258
}
257
259
// should not pass value to finally callback
258
- const value = zone . run ( delegate , undefined , isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [ ] : [ parentPromiseValue ] ) ;
260
+ const value = zone . run (
261
+ delegate , undefined ,
262
+ isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ?
263
+ [ ] :
264
+ [ parentPromiseValue ] ) ;
259
265
resolvePromise ( chainPromise , true , value ) ;
260
266
} catch ( error ) {
261
267
// if error occurs, should always return this error
@@ -272,11 +278,11 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
272
278
}
273
279
274
280
static resolve < R > ( value : R ) : Promise < R > {
275
- return resolvePromise ( < ZoneAwarePromise < R > > new this ( null ) , RESOLVED , value ) ;
281
+ return resolvePromise ( < ZoneAwarePromise < R > > new this ( null as any ) , RESOLVED , value ) ;
276
282
}
277
283
278
284
static reject < U > ( error : U ) : Promise < U > {
279
- return resolvePromise ( < ZoneAwarePromise < U > > new this ( null ) , REJECTED , error ) ;
285
+ return resolvePromise ( < ZoneAwarePromise < U > > new this ( null as any ) , REJECTED , error ) ;
280
286
}
281
287
282
288
static race < R > ( values : PromiseLike < any > [ ] ) : Promise < R > {
@@ -323,10 +329,10 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
323
329
resolve ( resolvedValues ) ;
324
330
}
325
331
} ) ( count ) ,
326
- reject ) ;
332
+ reject ! ) ;
327
333
count ++ ;
328
334
}
329
- if ( ! count ) resolve ( resolvedValues ) ;
335
+ if ( ! count ) resolve ! ( resolvedValues ) ;
330
336
return promise ;
331
337
}
332
338
@@ -351,7 +357,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
351
357
onRejected ?: ( ( reason : any ) => TResult2 | PromiseLike < TResult2 > ) | undefined |
352
358
null ) : Promise < TResult1 | TResult2 > {
353
359
const chainPromise : Promise < TResult1 | TResult2 > =
354
- new ( this . constructor as typeof ZoneAwarePromise ) ( null ) ;
360
+ new ( this . constructor as typeof ZoneAwarePromise ) ( null as any ) ;
355
361
const zone = Zone . current ;
356
362
if ( ( this as any ) [ symbolState ] == UNRESOLVED ) {
357
363
( < any [ ] > ( this as any ) [ symbolValue ] ) . push ( zone , chainPromise , onFulfilled , onRejected ) ;
@@ -368,7 +374,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
368
374
369
375
finally < U > ( onFinally ?: ( ) => U | PromiseLike < U > ) : Promise < R > {
370
376
const chainPromise : Promise < R | never > =
371
- new ( this . constructor as typeof ZoneAwarePromise ) ( null ) ;
377
+ new ( this . constructor as typeof ZoneAwarePromise ) ( null as any ) ;
372
378
( chainPromise as any ) [ symbolFinally ] = symbolFinally ;
373
379
const zone = Zone . current ;
374
380
if ( ( this as any ) [ symbolState ] == UNRESOLVED ) {
0 commit comments