From 5db9488c07b60336f889c1681e910cb41a8f8298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noel=20Kim=20=28=EA=B9=80=EB=AF=BC=ED=98=81=29?= Date: Wed, 18 May 2022 17:55:10 +0900 Subject: [PATCH] fix(chore): type guard for globalWindow --- lib/channel-postmessage/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/channel-postmessage/src/index.ts b/lib/channel-postmessage/src/index.ts index c4221f5509d4..c14dc401cd6f 100644 --- a/lib/channel-postmessage/src/index.ts +++ b/lib/channel-postmessage/src/index.ts @@ -35,7 +35,9 @@ export class PostmsgTransport { constructor(private readonly config: Config) { this.buffer = []; this.handler = null; - globalWindow.addEventListener('message', this.handleEvent.bind(this), false); + if (globalWindow) { + globalWindow.addEventListener('message', this.handleEvent.bind(this), false); + } // Check whether the config.page parameter has a valid value if (config.page !== 'manager' && config.page !== 'preview') {