1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

解决一处 ts 类型定义问题 (function: getUserConfigurations)

This commit is contained in:
程序员小墨 2024-12-04 00:03:32 +08:00
parent 57d6be7019
commit 4c51b72892
4 changed files with 5 additions and 5 deletions

View File

@ -98,7 +98,7 @@ export function handleQuickPick() {
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
// 获取用户配置 // 获取用户配置
const disableFormatList = getUserConfigurations('disableFormat'); const disableFormatList = getUserConfigurations<Array<string>>('disableFormat') || [];
// 排除禁用的选项 // 排除禁用的选项
const enabledQuickPickSupportCases = []; const enabledQuickPickSupportCases = [];
for (const quickPick of quickPickSupportCases) { for (const quickPick of quickPickSupportCases) {

View File

@ -44,7 +44,7 @@ export function activate(context: vscode.ExtensionContext) {
// issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1 // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
// 获取用户配置 // 获取用户配置
const disableFormatList = getUserConfigurations('disableFormat'); const disableFormatList = getUserConfigurations<Array<string>>('disableFormat') || [];
// 更新右键菜单每一项是否展示 // 更新右键菜单每一项是否展示
for (const { settingsKey } of commands) { for (const { settingsKey } of commands) {
vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, disableFormatList.includes(settingsKey)); vscode.commands.executeCommand('setContext', '_isHideSubMenuItem_' + settingsKey, disableFormatList.includes(settingsKey));

View File

@ -7,10 +7,10 @@ import vscode from 'vscode';
* @returns * @returns
* @since 2024-07-29 * @since 2024-07-29
*/ */
function getUserConfigurations(configKey: string) { function getUserConfigurations<T>(configKey: string): T | undefined {
const config = vscode.workspace.getConfiguration('variable-conversion'); const config = vscode.workspace.getConfiguration('variable-conversion');
const configValue = config.get(configKey); const configValue = config.get<T>(configKey);
console.log('configValue:', configValue); console.log('configValue:', configValue);
return configValue; return configValue;
} }

View File

@ -66,7 +66,7 @@ function lazyConvert() {
} }
// 获取用户配置 // 获取用户配置
const disableFormatList = getUserConfigurations('disableFormat'); const disableFormatList = getUserConfigurations<Array<string>>('disableFormat') || [];
const textList = userSelection.currentSelectionsText; const textList = userSelection.currentSelectionsText;
// vscode.window.showInformationMessage('lazyConvert' + textList.join('\n')); // vscode.window.showInformationMessage('lazyConvert' + textList.join('\n'));