diff --git a/src/Observable.ts b/src/Observable.ts index 0aa4b4cef3..87bf88cc63 100644 --- a/src/Observable.ts +++ b/src/Observable.ts @@ -139,7 +139,10 @@ export class Observable implements Subscribable { } return new PromiseCtor((resolve, reject) => { - const subscription = this.subscribe((value) => { + // Must be declared in a separate statement to avoid a RefernceError when + // accessing subscription below in the closure due to Temporal Dead Zone. + let subscription: Subscription; + subscription = this.subscribe((value) => { if (subscription) { // if there is a subscription, then we can surmise // the next handling is asynchronous. Any errors thrown