diff --git a/src/extension-handler/quick-pick-handler.ts b/src/extension-handler/quick-pick-handler.ts index 0c59bf8..edc283f 100644 --- a/src/extension-handler/quick-pick-handler.ts +++ b/src/extension-handler/quick-pick-handler.ts @@ -98,7 +98,7 @@ export function handleQuickPick() { // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 // 获取用户配置 - const disableFormatList = getUserConfigurations('disableFormat'); + const disableFormatList = getUserConfigurations>('disableFormat') || []; // 排除禁用的选项 const enabledQuickPickSupportCases = []; for (const quickPick of quickPickSupportCases) { diff --git a/src/extension.ts b/src/extension.ts index 48eb6f0..95d26e1 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -44,7 +44,7 @@ export function activate(context: vscode.ExtensionContext) { // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 // 获取用户配置 - const disableFormatList = getUserConfigurations('disableFormat'); + const disableFormatList = getUserConfigurations>('disableFormat') || []; // 更新右键菜单每一项是否展示 for (const { settingsKey } of commands) { vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, disableFormatList.includes(settingsKey)); diff --git a/src/main-code/user-configuration.ts b/src/main-code/user-configuration.ts index 3fb93d0..536968f 100644 --- a/src/main-code/user-configuration.ts +++ b/src/main-code/user-configuration.ts @@ -7,10 +7,10 @@ import vscode from 'vscode'; * @returns 配置项的值 * @since 2024-07-29 */ -function getUserConfigurations(configKey: string) { +function getUserConfigurations(configKey: string): T | undefined { const config = vscode.workspace.getConfiguration('variable-conversion'); - const configValue = config.get(configKey); + const configValue = config.get(configKey); console.log('configValue:', configValue); return configValue; } diff --git a/src/main-code/variable-convert/cyclic-conversion.ts b/src/main-code/variable-convert/cyclic-conversion.ts index 90064a9..40027ce 100644 --- a/src/main-code/variable-convert/cyclic-conversion.ts +++ b/src/main-code/variable-convert/cyclic-conversion.ts @@ -66,7 +66,7 @@ function lazyConvert() { } // 获取用户配置 - const disableFormatList = getUserConfigurations('disableFormat'); + const disableFormatList = getUserConfigurations>('disableFormat') || []; const textList = userSelection.currentSelectionsText; // vscode.window.showInformationMessage('lazyConvert' + textList.join('\n'));