fix(store): fix TypeError: Cannot convert undefined or null to object

This commit is contained in:
JellyBrick
2023-11-28 05:51:47 +09:00
parent ac0b78eefb
commit 09450fb8c7

View File

@ -85,28 +85,29 @@ const migrations = {
shortcut: unknown; shortcut: unknown;
}[] }[]
| Record<string, unknown> | Record<string, unknown>
>; > | undefined;
let updated = false; if (options) {
for (const optionType of ['global', 'local']) { let updated = false;
if (Object.hasOwn(options, optionType) && Array.isArray(options[optionType])) { for (const optionType of ['global', 'local']) {
const optionsArray = options[optionType] as { if (Object.hasOwn(options, optionType) && Array.isArray(options[optionType])) {
action: string; const optionsArray = options[optionType] as {
shortcut: unknown; action: string;
}[]; shortcut: unknown;
const updatedOptions: Record<string, unknown> = {}; }[];
for (const optionObject of optionsArray) { const updatedOptions: Record<string, unknown> = {};
if (optionObject.action && optionObject.shortcut) { for (const optionObject of optionsArray) {
updatedOptions[optionObject.action] = optionObject.shortcut; 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<Record<string, unknown>>) { '>=1.11.0'(store: Conf<Record<string, unknown>>) {