From 4cfc8bd4b3f129f5c5b5a331a10a347a6a245f39 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Thu, 16 Jul 2020 21:20:55 +0200 Subject: [PATCH] fix accessing nonexisting config property during appState clearing (#1928) --- src/appState.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/appState.ts b/src/appState.ts index e10d8813..76d21281 100644 --- a/src/appState.ts +++ b/src/appState.ts @@ -139,7 +139,13 @@ const _clearAppStateForStorage = ( }[keyof typeof APP_STATE_STORAGE_CONF]; const stateForExport = {} as { [K in ExportableKeys]?: typeof appState[K] }; for (const key of Object.keys(appState) as (keyof typeof appState)[]) { - if (APP_STATE_STORAGE_CONF[key][exportType]) { + const propConfig = APP_STATE_STORAGE_CONF[key]; + if (!propConfig) { + console.error( + `_clearAppStateForStorage: appState key "${key}" config doesn't exist for "${exportType}" export type`, + ); + } + if (propConfig?.[exportType]) { // @ts-ignore see https://github.com/microsoft/TypeScript/issues/31445 stateForExport[key] = appState[key]; }