(onFinally?: () => U | PromiseLike<U>)
| 558 | } |
| 559 | |
| 560 | finally<U>(onFinally?: () => U | PromiseLike<U>): Promise<R> { |
| 561 | // See comment on the call to `then` about why thee `Symbol.species` is safely accessed. |
| 562 | let C = (this.constructor as any)?.[Symbol.species]; |
| 563 | if (!C || typeof C !== 'function') { |
| 564 | C = ZoneAwarePromise; |
| 565 | } |
| 566 | const chainPromise: Promise<R | never> = new (C as typeof ZoneAwarePromise)(noop); |
| 567 | (chainPromise as any)[symbolFinally] = symbolFinally; |
| 568 | const zone = Zone.current; |
| 569 | if ((this as any)[symbolState] == UNRESOLVED) { |
| 570 | (<any[]>(this as any)[symbolValue]).push(zone, chainPromise, onFinally, onFinally); |
| 571 | } else { |
| 572 | scheduleResolveOrReject(this, zone, chainPromise as any, onFinally, onFinally); |
| 573 | } |
| 574 | return chainPromise; |
| 575 | } |
| 576 | } |
| 577 | // Protect against aggressive optimizers dropping seemingly unused properties. |
| 578 | // E.g. Closure Compiler in advanced mode. |
no test coverage detected