From 09450fb8c715d60f774c5c818a90c2124cc84833 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Tue, 28 Nov 2023 05:51:47 +0900 Subject: [PATCH] fix(store): fix `TypeError: Cannot convert undefined or null to object` --- src/config/store.ts | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/config/store.ts b/src/config/store.ts index fb042af5..57721ee0 100644 --- a/src/config/store.ts +++ b/src/config/store.ts @@ -85,28 +85,29 @@ const migrations = { shortcut: unknown; }[] | Record - >; - let updated = false; - for (const optionType of ['global', 'local']) { - if (Object.hasOwn(options, optionType) && Array.isArray(options[optionType])) { - const optionsArray = options[optionType] as { - action: string; - shortcut: unknown; - }[]; - const updatedOptions: Record = {}; - for (const optionObject of optionsArray) { - if (optionObject.action && optionObject.shortcut) { - updatedOptions[optionObject.action] = optionObject.shortcut; + > | undefined; + if (options) { + let updated = false; + for (const optionType of ['global', 'local']) { + if (Object.hasOwn(options, optionType) && Array.isArray(options[optionType])) { + const optionsArray = options[optionType] as { + action: string; + shortcut: unknown; + }[]; + const updatedOptions: Record = {}; + for (const optionObject of optionsArray) { + if (optionObject.action && optionObject.shortcut) { + updatedOptions[optionObject.action] = optionObject.shortcut; + } } + + options[optionType] = updatedOptions; + updated = true; } - - options[optionType] = updatedOptions; - updated = true; } - } - - if (updated) { - store.set('plugins.shortcuts', options); + if (updated) { + store.set('plugins.shortcuts', options); + } } }, '>=1.11.0'(store: Conf>) {