diff --git a/spec/Subscriber-spec.ts b/spec/Subscriber-spec.ts index f4d63bccce..72169b83b9 100644 --- a/spec/Subscriber-spec.ts +++ b/spec/Subscriber-spec.ts @@ -244,7 +244,7 @@ describe('Subscriber', () => { }); const FinalizationRegistry = (global as any).FinalizationRegistry; - if (FinalizationRegistry) { + if (FinalizationRegistry && global.gc) { it('should not leak the destination', (done) => { let observer: Observer | undefined = { @@ -262,7 +262,7 @@ describe('Subscriber', () => { const subscription = of(42).subscribe(observer); observer = undefined; - global.gc(); + global.gc?.(); }); } else { diff --git a/spec/operators/shareReplay-spec.ts b/spec/operators/shareReplay-spec.ts index 0b336dac74..86f115232d 100644 --- a/spec/operators/shareReplay-spec.ts +++ b/spec/operators/shareReplay-spec.ts @@ -366,7 +366,7 @@ describe('shareReplay', () => { }); const FinalizationRegistry = (global as any).FinalizationRegistry; - if (FinalizationRegistry) { + if (FinalizationRegistry && global.gc) { it('should not leak the subscriber for sync sources', (done) => { let callback: (() => void) | undefined = () => { /* noop */ @@ -382,7 +382,7 @@ describe('shareReplay', () => { shared.subscribe(callback); callback = undefined; - global.gc(); + global.gc?.(); }); } else { console.warn(`No support for FinalizationRegistry in Node ${process.version}`); diff --git a/spec/schedulers/intervalProvider-spec.ts b/spec/schedulers/intervalProvider-spec.ts index 990bf6cbfa..55bf3f9690 100644 --- a/spec/schedulers/intervalProvider-spec.ts +++ b/spec/schedulers/intervalProvider-spec.ts @@ -15,10 +15,10 @@ describe('intervalProvider', () => { let setCalled = false; let clearCalled = false; - global.setInterval = () => { + global.setInterval = (() => { setCalled = true; return 0 as any; - }; + }) as any; // TypeScript complains about a __promisify__ property global.clearInterval = () => { clearCalled = true; };