Don't pretend to have a WorkspaceConfiguration if there isn't one
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 073ff2f..cb71a01 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -13,7 +13,7 @@
export async function createClient(
traceOutputChannel: vscode.OutputChannel,
outputChannel: vscode.OutputChannel,
- initializationOptions: vscode.WorkspaceConfiguration,
+ initializationOptions: lc.LanguageClientOptions["initializationOptions"],
serverOptions: lc.ServerOptions,
config: Config,
unlinkedFiles: vscode.Uri[],
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 3b1b076..06e179e 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -5,6 +5,7 @@
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 @@
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 @@
* 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 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;
}