@@ -46,7 +46,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
4646 api . microtaskDrainDone = ( ) => {
4747 while ( _uncaughtPromiseErrors . length ) {
4848 while ( _uncaughtPromiseErrors . length ) {
49- const uncaughtPromiseError : UncaughtPromiseError = _uncaughtPromiseErrors . shift ( ) ;
49+ const uncaughtPromiseError : UncaughtPromiseError = _uncaughtPromiseErrors . shift ( ) ! ;
5050 try {
5151 uncaughtPromiseError . zone . runGuarded ( ( ) => {
5252 throw uncaughtPromiseError ;
@@ -164,7 +164,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
164164 ( promise as any ) [ symbolValue ] = value ;
165165
166166 if ( ( promise as any ) [ symbolFinally ] === symbolFinally ) {
167- // the promise is generated by Promise.prototype.finally
167+ // the promise is generated by Promise.prototype.finally
168168 if ( state === RESOLVED ) {
169169 // the state is resolved, should ignore the value
170170 // and use parent promise value
@@ -202,7 +202,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
202202 error . rejection = value ;
203203 error . promise = promise ;
204204 error . zone = Zone . current ;
205- error . task = Zone . currentTask ;
205+ error . task = Zone . currentTask ! ;
206206 _uncaughtPromiseErrors . push ( error ) ;
207207 api . scheduleMicroTask ( ) ; // to make sure that it is running
208208 }
@@ -239,7 +239,8 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
239239
240240 function scheduleResolveOrReject < R , U1 , U2 > (
241241 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 {
243244 clearRejectedNoCatch ( promise ) ;
244245 const promiseState = ( promise as any ) [ symbolState ] ;
245246 const delegate = promiseState ?
@@ -248,14 +249,19 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
248249 zone . scheduleMicroTask ( source , ( ) => {
249250 try {
250251 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 ] ;
252254 if ( isFinallyPromise ) {
253255 // if the promise is generated from finally call, keep parent promise's state and value
254256 ( chainPromise as any ) [ symbolParentPromiseValue ] = parentPromiseValue ;
255257 ( chainPromise as any ) [ symbolParentPromiseState ] = promiseState ;
256258 }
257259 // 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 ] ) ;
259265 resolvePromise ( chainPromise , true , value ) ;
260266 } catch ( error ) {
261267 // if error occurs, should always return this error
@@ -272,11 +278,11 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
272278 }
273279
274280 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 ) ;
276282 }
277283
278284 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 ) ;
280286 }
281287
282288 static race < R > ( values : PromiseLike < any > [ ] ) : Promise < R > {
@@ -323,10 +329,10 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
323329 resolve ( resolvedValues ) ;
324330 }
325331 } ) ( count ) ,
326- reject ) ;
332+ reject ! ) ;
327333 count ++ ;
328334 }
329- if ( ! count ) resolve ( resolvedValues ) ;
335+ if ( ! count ) resolve ! ( resolvedValues ) ;
330336 return promise ;
331337 }
332338
@@ -351,7 +357,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
351357 onRejected ?: ( ( reason : any ) => TResult2 | PromiseLike < TResult2 > ) | undefined |
352358 null ) : Promise < TResult1 | TResult2 > {
353359 const chainPromise : Promise < TResult1 | TResult2 > =
354- new ( this . constructor as typeof ZoneAwarePromise ) ( null ) ;
360+ new ( this . constructor as typeof ZoneAwarePromise ) ( null as any ) ;
355361 const zone = Zone . current ;
356362 if ( ( this as any ) [ symbolState ] == UNRESOLVED ) {
357363 ( < any [ ] > ( this as any ) [ symbolValue ] ) . push ( zone , chainPromise , onFulfilled , onRejected ) ;
@@ -368,7 +374,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
368374
369375 finally < U > ( onFinally ?: ( ) => U | PromiseLike < U > ) : Promise < R > {
370376 const chainPromise : Promise < R | never > =
371- new ( this . constructor as typeof ZoneAwarePromise ) ( null ) ;
377+ new ( this . constructor as typeof ZoneAwarePromise ) ( null as any ) ;
372378 ( chainPromise as any ) [ symbolFinally ] = symbolFinally ;
373379 const zone = Zone . current ;
374380 if ( ( this as any ) [ symbolState ] == UNRESOLVED ) {
0 commit comments