Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/config.ts')
-rw-r--r--editors/code/src/config.ts20
1 files changed, 11 insertions, 9 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 3b1b0768d3..06e179eb0e 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -5,6 +5,7 @@ import * as vscode from "vscode";
import { expectNotUndefined, log, normalizeDriveLetter, unwrapUndefinable } from "./util";
import type { Env } from "./util";
import type { Disposable } from "vscode";
+import { get } from "lodash";
export type RunnableEnvCfgItem = {
mask?: string;
@@ -12,6 +13,9 @@ export type RunnableEnvCfgItem = {
platform?: string | string[];
};
+export type ConfigurationTree = { [key: string]: ConfigurationValue };
+export type ConfigurationValue = undefined | null | boolean | number | string | ConfigurationValue[] | ConfigurationTree;
+
type ShowStatusBar = "always" | "never" | { documentSelector: vscode.DocumentSelector };
export class Config {
@@ -197,7 +201,7 @@ export class Config {
* So this getter handles this quirk by not requiring the caller to use postfix `!`
*/
private get<T>(path: string): T | undefined {
- return prepareVSCodeConfig(this.cfg.get<T>(path));
+ return prepareVSCodeConfig(get(this.cfg, path)) as T;
}
get serverPath() {
@@ -371,22 +375,20 @@ export class Config {
}
}
-export function prepareVSCodeConfig<T>(resp: T): T {
+export function prepareVSCodeConfig(resp: ConfigurationValue): ConfigurationValue {
if (Is.string(resp)) {
- return substituteVSCodeVariableInString(resp) as T;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- } else if (resp && Is.array<any>(resp)) {
+ return substituteVSCodeVariableInString(resp);
+ } else if (resp && Is.array(resp)) {
return resp.map((val) => {
return prepareVSCodeConfig(val);
- }) as T;
+ });
} else if (resp && typeof resp === "object") {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const res: { [key: string]: any } = {};
+ const res: ConfigurationTree = {};
for (const key in resp) {
const val = resp[key];
res[key] = prepareVSCodeConfig(val);
}
- return res as T;
+ return res;
}
return resp;
}