diff --git a/packages/jest-environment-jsdom/src/index.ts b/packages/jest-environment-jsdom/src/index.ts index 8d0c33c1df7c..88a976d267c9 100644 --- a/packages/jest-environment-jsdom/src/index.ts +++ b/packages/jest-environment-jsdom/src/index.ts @@ -15,13 +15,14 @@ import {JSDOM, VirtualConsole} from 'jsdom'; // The `Window` interface does not have an `Error.stackTraceLimit` property, but // `JSDOMEnvironment` assumes it is there. -interface Win extends Window { - Error: { - stackTraceLimit: number; +type Win = Window & + Global.Global & { + Error: { + stackTraceLimit: number; + }; }; -} -function isWin(globals: Win | Global.Global): globals is Win { +function isWin(globals: Win): globals is Win { return (globals as Win).document !== undefined; } @@ -31,8 +32,7 @@ function isWin(globals: Win | Global.Global): globals is Win { class JSDOMEnvironment implements JestEnvironment { dom: JSDOM | null; fakeTimers: FakeTimers | null; - // @ts-ignore - global: Global.Global | Win | null; + global: Win; errorEventListener: ((event: Event & {error: Error}) => void) | null; moduleMocker: ModuleMocker | null; @@ -119,6 +119,7 @@ class JSDOMEnvironment implements JestEnvironment { } } this.errorEventListener = null; + // @ts-ignore this.global = null; this.dom = null; this.fakeTimers = null;