소스 검색

fix accessing nonexisting config property during appState clearing (#1928)

David Luzar 5 년 전
부모
커밋
4cfc8bd4b3
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      src/appState.ts

+ 7 - 1
src/appState.ts

@@ -139,7 +139,13 @@ const _clearAppStateForStorage = <ExportType extends "export" | "browser">(
   }[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];
     }