@@ -5,13 +5,17 @@ import * as vscode from "vscode";
55import { expectNotUndefined , log , normalizeDriveLetter , unwrapUndefinable } from "./util" ;
66import type { Env } from "./util" ;
77import type { Disposable } from "vscode" ;
8+ import { get } from "lodash" ;
89
910export type RunnableEnvCfgItem = {
1011 mask ?: string ;
1112 env : { [ key : string ] : { toString ( ) : string } | null } ;
1213 platform ?: string | string [ ] ;
1314} ;
1415
16+ export type ConfigurationTree = { [ key : string ] : ConfigurationValue } ;
17+ export type ConfigurationValue = undefined | null | boolean | number | string | ConfigurationValue [ ] | ConfigurationTree ;
18+
1519type ShowStatusBar = "always" | "never" | { documentSelector : vscode . DocumentSelector } ;
1620
1721export class Config {
@@ -197,7 +201,7 @@ export class Config {
197201 * So this getter handles this quirk by not requiring the caller to use postfix `!`
198202 */
199203 private get < T > ( path : string ) : T | undefined {
200- return prepareVSCodeConfig ( this . cfg . get < T > ( path ) ) ;
204+ return prepareVSCodeConfig ( get ( this . cfg , path ) ) as T ;
201205 }
202206
203207 get serverPath ( ) {
@@ -371,22 +375,20 @@ export class Config {
371375 }
372376}
373377
374- export function prepareVSCodeConfig < T > ( resp : T ) : T {
378+ export function prepareVSCodeConfig ( resp : ConfigurationValue ) : ConfigurationValue {
375379 if ( Is . string ( resp ) ) {
376- return substituteVSCodeVariableInString ( resp ) as T ;
377- // eslint-disable-next-line @typescript-eslint/no-explicit-any
378- } else if ( resp && Is . array < any > ( resp ) ) {
380+ return substituteVSCodeVariableInString ( resp ) ;
381+ } else if ( resp && Is . array ( resp ) ) {
379382 return resp . map ( ( val ) => {
380383 return prepareVSCodeConfig ( val ) ;
381- } ) as T ;
384+ } ) ;
382385 } else if ( resp && typeof resp === "object" ) {
383- // eslint-disable-next-line @typescript-eslint/no-explicit-any
384- const res : { [ key : string ] : any } = { } ;
386+ const res : ConfigurationTree = { } ;
385387 for ( const key in resp ) {
386388 const val = resp [ key ] ;
387389 res [ key ] = prepareVSCodeConfig ( val ) ;
388390 }
389- return res as T ;
391+ return res ;
390392 }
391393 return resp ;
392394}
0 commit comments