From 8b0ebb3a38ed456c655b9c723cfea4f0d782a8f2 Mon Sep 17 00:00:00 2001 From: "Kuang-Chen (KC) Lu" Date: Wed, 14 Oct 2026 15:28:10 -0400 Subject: [PATCH 1/5] Enable noImplicitAny - addServer/getServerNames: type the servers object read from settings - importFromRegistry: minimal NodeCmd interface, typed helper parameters, fuller ServerDefinition - BasicAuthorization/OAuth2Authorization.resolve: parameter typed as the interface declares - makeRESTRequest: merge credentials by name instead of indexing the request with a string - runTest launchArgs, serverManagerView project callback: explicit types --- src/api/addServer.ts | 2 +- src/api/getServerNames.ts | 3 ++- src/commands/importFromRegistry.ts | 17 ++++++++++++----- src/commonActivate.ts | 4 ++-- src/makeRESTRequest.ts | 16 ++++++++-------- src/test/runTest.ts | 2 +- src/ui/serverManagerView.ts | 2 +- tsconfig.json | 2 +- 8 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/api/addServer.ts b/src/api/addServer.ts index b12e713b..6da85013 100644 --- a/src/api/addServer.ts +++ b/src/api/addServer.ts @@ -163,7 +163,7 @@ export async function addServer( "intersystems", scope, ); - const serversInspection = config.inspect("servers"); + const serversInspection = config.inspect>>("servers"); const servers = ( target == vscode.ConfigurationTarget.WorkspaceFolder ? serversInspection?.workspaceFolderValue : target == vscode.ConfigurationTarget.Workspace ? serversInspection?.workspaceValue : diff --git a/src/api/getServerNames.ts b/src/api/getServerNames.ts index bb9e217f..36d81b1b 100644 --- a/src/api/getServerNames.ts +++ b/src/api/getServerNames.ts @@ -1,11 +1,12 @@ import { IServerName } from "@intersystems-community/intersystems-servermanager"; import * as vscode from "vscode"; +import { IServerSetting } from "../serverSetting"; import { serverDetail } from "./getServerSummary"; export function getServerNames(scope?: vscode.ConfigurationScope, sorted?: boolean): IServerName[] { const allNames: IServerName[] = []; const names: IServerName[] = []; - const servers = vscode.workspace.getConfiguration("intersystems", scope).get("servers"); + const servers = vscode.workspace.getConfiguration("intersystems", scope).get & { "/default"?: string }>("servers"); if (typeof servers === "object" && servers) { diff --git a/src/commands/importFromRegistry.ts b/src/commands/importFromRegistry.ts index 7dbeb387..3479654d 100644 --- a/src/commands/importFromRegistry.ts +++ b/src/commands/importFromRegistry.ts @@ -4,6 +4,11 @@ import { ServerManagerAuthenticationProvider } from "../authenticationProvider"; // To avoid overhead querying the registry, cache responses (each time the command is run) const regQueryCache = new Map(); +/** The parts of node-cmd we use; the package ships no types */ +interface NodeCmd { + runSync(command: string): { data: string | null }; +} + export async function importFromRegistry(secretStorage: vscode.SecretStorage, scope?: vscode.ConfigurationScope) { const config = vscode.workspace.getConfiguration("intersystems", scope); const serverDefinitions: ServerDefinitions = config.get("servers") ?? {}; @@ -64,11 +69,11 @@ export async function importFromRegistry(secretStorage: vscode.SecretStorage, sc async function loadRegistryData( config: vscode.WorkspaceConfiguration, - serverDefinitions, + serverDefinitions: ServerDefinitions, serversMissingUsernames: string[], newServerNames: string[], ): Promise { - const cmd = require("node-cmd"); + const cmd: NodeCmd = require("node-cmd"); const subFolder = "\\Intersystems\\Cache\\Servers"; const fullPaths: string[] = []; fullPaths.push("HKEY_CURRENT_USER\\SOFTWARE" + subFolder); @@ -206,6 +211,8 @@ async function promptForUsernames(serverDefinitions: ServerDefinitions, serversM export interface ServerDefinition { username?: string; + description?: string; + webServer?: { scheme: string; host?: string; port: number; pathPrefix?: string }; } export type ServerDefinitions = Record; @@ -269,7 +276,7 @@ async function promptForPasswords(secretStorage: vscode.SecretStorage, serverDef } } -function preloadRegistryCache(cmd, fullPath) { +function preloadRegistryCache(cmd: NodeCmd, fullPath: string) { const regData = cmd.runSync("reg query " + fullPath + " /s"); if (!regData.data) { return; @@ -283,13 +290,13 @@ function preloadRegistryCache(cmd, fullPath) { }); } -function getStringRegKey(cmd, hive, path, key): string | undefined { +function getStringRegKey(cmd: NodeCmd, hive: string, path: string, key: string): string | undefined { const queryPath = hive + "\\" + path; const regData = regQueryCache.get(queryPath) || cmd.runSync("reg query " + queryPath); if (!regData.data) { return undefined; } - regQueryCache.set(queryPath, regData); + regQueryCache.set(queryPath, { data: regData.data }); const results = regData.data.split("\r\n") // Result lines from reg query are 4-space-delimited .map((line) => line.split(" ")) diff --git a/src/commonActivate.ts b/src/commonActivate.ts index 99ce8ec1..7db54e89 100644 --- a/src/commonActivate.ts +++ b/src/commonActivate.ts @@ -50,7 +50,7 @@ export class BasicAuthorization implements Authorization { return this.username !== "" && this.#password !== undefined; } - public resolve({ accessToken, username }): this is ResolvedAuthorization { + public resolve({ accessToken, username }: { accessToken?: string; username?: string }): this is ResolvedAuthorization { this.#username = username ?? this.#username; this.#password = accessToken ?? this.#password; return this.resolved(); @@ -92,7 +92,7 @@ export class OAuth2Authorization implements Authorization { return this.#bearer ? true : false; } - public resolve({ accessToken, username }): this is ResolvedAuthorization { + public resolve({ accessToken, username }: { accessToken?: string; username?: string }): this is ResolvedAuthorization { // empty accessTokens are ignored. if (accessToken) { this.#bearer = accessToken; diff --git a/src/makeRESTRequest.ts b/src/makeRESTRequest.ts index f9d95404..10236464 100644 --- a/src/makeRESTRequest.ts +++ b/src/makeRESTRequest.ts @@ -104,12 +104,12 @@ export async function makeRESTRequest( if (!server.auth.resolved()) { throw Error("Internal error: Credentials were not resolved"); } - for (const [k, v] of Object.entries(server.auth.credentials)) { - if (typeof v === "object") { - request[k] = Object.assign({}, request[k], v); - } else { - request[k] = v; - } + const { auth, headers } = server.auth.credentials; + if (auth) { + request.auth = auth; + } + if (headers) { + request.headers = { ...request.headers, ...headers }; } respdata = await axios.request(request); } @@ -206,11 +206,11 @@ async function resolveCredentials(spec: IServerSpec & { auth: Authorization }): * If `error` is `undefined`, returns the empty string. * Borrowed from `vscode-objectscript:/src/utils/index.ts` */ -function stringifyError(error): string { +function stringifyError(error: any): string { try { if (Array.isArray(error?.errors)) { // Need to stringify the inner errors of an AggregateError - const errs = error.errors.map(stringifyError).filter((s) => s != ""); + const errs = error.errors.map(stringifyError).filter((s: string) => s != ""); return errs.length ? `AggregateError:\n- ${errs.join("\n- ")}` : ""; } return ( diff --git a/src/test/runTest.ts b/src/test/runTest.ts index a93191fd..cc176e92 100644 --- a/src/test/runTest.ts +++ b/src/test/runTest.ts @@ -12,7 +12,7 @@ async function main() { // Passed to --extensionTestsPath const extensionTestsPath = path.resolve(__dirname, "./suite/index"); - const launchArgs = []; + const launchArgs: string[] = []; // Download VS Code, unzip it and run the integration test await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs }); diff --git a/src/ui/serverManagerView.ts b/src/ui/serverManagerView.ts index 44101f15..33b343bb 100644 --- a/src/ui/serverManagerView.ts +++ b/src/ui/serverManagerView.ts @@ -649,7 +649,7 @@ async function namespaceProjects(element: ProjectsTreeItem, params?: ServerParam vscode.window.showErrorMessage(message); return undefined; } - response.data.result.content.map((project) => { + response.data.result.content.map((project: { Name: string; Description: string }) => { children.push(new ProjectTreeItem({ parent: element, label: name, id: name }, project.Name, project.Description, params.serverApiVersion!)); }); } diff --git a/tsconfig.json b/tsconfig.json index 13da9b41..e3a6b4ed 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "es2019", - "noImplicitAny": false, + "noImplicitAny": true, "removeComments": false, "noUnusedLocals": true, "noImplicitThis": true, From 8d3c552ac52da5353366184a6b7fc7f2aacd68d1 Mon Sep 17 00:00:00 2001 From: "Kuang-Chen (KC) Lu" Date: Wed, 14 Oct 2026 15:32:51 -0400 Subject: [PATCH 2/5] Keep the credentials loop; widen the request type instead --- src/makeRESTRequest.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/makeRESTRequest.ts b/src/makeRESTRequest.ts index 10236464..fc105fdc 100644 --- a/src/makeRESTRequest.ts +++ b/src/makeRESTRequest.ts @@ -72,7 +72,7 @@ export async function makeRESTRequest( url += "v" + String(endpoint.apiVersion) + "/" + endpoint.namespace + endpoint.path; } - const request: AxiosRequestConfig & { headers: {}, data?: any } = { + const request: AxiosRequestConfig & { headers: {}, data?: any, [key: string]: any } = { httpsAgent, headers: {}, method, @@ -104,12 +104,12 @@ export async function makeRESTRequest( if (!server.auth.resolved()) { throw Error("Internal error: Credentials were not resolved"); } - const { auth, headers } = server.auth.credentials; - if (auth) { - request.auth = auth; - } - if (headers) { - request.headers = { ...request.headers, ...headers }; + for (const [k, v] of Object.entries(server.auth.credentials)) { + if (typeof v === "object") { + request[k] = Object.assign({}, request[k], v); + } else { + request[k] = v; + } } respdata = await axios.request(request); } From c23d2b8feeb01fb6e165a7e7c6ae2822e30d77b6 Mon Sep 17 00:00:00 2001 From: "Kuang-Chen (KC) Lu" Date: Wed, 14 Oct 2026 15:35:43 -0400 Subject: [PATCH 3/5] Use @types/node-cmd instead of a local interface --- package-lock.json | 11 +++++++++++ package.json | 1 + src/commands/importFromRegistry.ts | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index ca8df192..6ce078d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@types/glob": "^7.1.1", "@types/mocha": "^9.0.0", "@types/node": "^20.14.0", + "@types/node-cmd": "^5.0.0", "@types/vscode": "^1.109.0", "@vscode/test-electron": "^2.5.2", "glob": "^7.1.6", @@ -251,6 +252,16 @@ "undici-types": "~6.21.0" } }, + "node_modules/@types/node-cmd": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/node-cmd/-/node-cmd-5.0.0.tgz", + "integrity": "sha512-HqBUPplSDx6GwrY0DABs5VwRRyGxVy053WqFpClTmt9hONe4dq8rWpuVS/WeDZzEV3XCb8BByxRrGvtBpqJ+kw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/vscode": { "version": "1.109.0", "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.109.0.tgz", diff --git a/package.json b/package.json index 7454b5ec..0b7b0f73 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "@types/glob": "^7.1.1", "@types/mocha": "^9.0.0", "@types/node": "^20.14.0", + "@types/node-cmd": "^5.0.0", "@types/vscode": "^1.109.0", "@vscode/test-electron": "^2.5.2", "glob": "^7.1.6", diff --git a/src/commands/importFromRegistry.ts b/src/commands/importFromRegistry.ts index 3479654d..4513380a 100644 --- a/src/commands/importFromRegistry.ts +++ b/src/commands/importFromRegistry.ts @@ -3,11 +3,7 @@ import { ServerManagerAuthenticationProvider } from "../authenticationProvider"; // To avoid overhead querying the registry, cache responses (each time the command is run) const regQueryCache = new Map(); - -/** The parts of node-cmd we use; the package ships no types */ -interface NodeCmd { - runSync(command: string): { data: string | null }; -} +type NodeCmd = typeof import("node-cmd"); export async function importFromRegistry(secretStorage: vscode.SecretStorage, scope?: vscode.ConfigurationScope) { const config = vscode.workspace.getConfiguration("intersystems", scope); From cd3436292c632dc8791892762a78c0127af085e5 Mon Sep 17 00:00:00 2001 From: "Kuang-Chen (KC) Lu" Date: Wed, 14 Oct 2026 15:38:49 -0400 Subject: [PATCH 4/5] Type node-cmd usage as explicit any with annotated results; drop @types/node-cmd --- package-lock.json | 11 ----------- package.json | 1 - src/commands/importFromRegistry.ts | 11 +++++------ 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6ce078d5..ca8df192 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,6 @@ "@types/glob": "^7.1.1", "@types/mocha": "^9.0.0", "@types/node": "^20.14.0", - "@types/node-cmd": "^5.0.0", "@types/vscode": "^1.109.0", "@vscode/test-electron": "^2.5.2", "glob": "^7.1.6", @@ -252,16 +251,6 @@ "undici-types": "~6.21.0" } }, - "node_modules/@types/node-cmd": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@types/node-cmd/-/node-cmd-5.0.0.tgz", - "integrity": "sha512-HqBUPplSDx6GwrY0DABs5VwRRyGxVy053WqFpClTmt9hONe4dq8rWpuVS/WeDZzEV3XCb8BByxRrGvtBpqJ+kw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/vscode": { "version": "1.109.0", "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.109.0.tgz", diff --git a/package.json b/package.json index 0b7b0f73..7454b5ec 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,6 @@ "@types/glob": "^7.1.1", "@types/mocha": "^9.0.0", "@types/node": "^20.14.0", - "@types/node-cmd": "^5.0.0", "@types/vscode": "^1.109.0", "@vscode/test-electron": "^2.5.2", "glob": "^7.1.6", diff --git a/src/commands/importFromRegistry.ts b/src/commands/importFromRegistry.ts index 4513380a..ed123714 100644 --- a/src/commands/importFromRegistry.ts +++ b/src/commands/importFromRegistry.ts @@ -3,7 +3,6 @@ import { ServerManagerAuthenticationProvider } from "../authenticationProvider"; // To avoid overhead querying the registry, cache responses (each time the command is run) const regQueryCache = new Map(); -type NodeCmd = typeof import("node-cmd"); export async function importFromRegistry(secretStorage: vscode.SecretStorage, scope?: vscode.ConfigurationScope) { const config = vscode.workspace.getConfiguration("intersystems", scope); @@ -69,7 +68,7 @@ async function loadRegistryData( serversMissingUsernames: string[], newServerNames: string[], ): Promise { - const cmd: NodeCmd = require("node-cmd"); + const cmd = require("node-cmd"); const subFolder = "\\Intersystems\\Cache\\Servers"; const fullPaths: string[] = []; fullPaths.push("HKEY_CURRENT_USER\\SOFTWARE" + subFolder); @@ -272,8 +271,8 @@ async function promptForPasswords(secretStorage: vscode.SecretStorage, serverDef } } -function preloadRegistryCache(cmd: NodeCmd, fullPath: string) { - const regData = cmd.runSync("reg query " + fullPath + " /s"); +function preloadRegistryCache(cmd: any, fullPath: string) { + const regData: { data: string | null } = cmd.runSync("reg query " + fullPath + " /s"); if (!regData.data) { return; } @@ -286,9 +285,9 @@ function preloadRegistryCache(cmd: NodeCmd, fullPath: string) { }); } -function getStringRegKey(cmd: NodeCmd, hive: string, path: string, key: string): string | undefined { +function getStringRegKey(cmd: any, hive: string, path: string, key: string): string | undefined { const queryPath = hive + "\\" + path; - const regData = regQueryCache.get(queryPath) || cmd.runSync("reg query " + queryPath); + const regData: { data?: string | null } = regQueryCache.get(queryPath) || cmd.runSync("reg query " + queryPath); if (!regData.data) { return undefined; } From 1546079dcf3d7a744afaae9eaf486c00fa9e835e Mon Sep 17 00:00:00 2001 From: "Kuang-Chen (KC) Lu" Date: Wed, 14 Oct 2026 15:39:24 -0400 Subject: [PATCH 5/5] Widen the registry cache value type instead of rebuilding the entry --- src/commands/importFromRegistry.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/importFromRegistry.ts b/src/commands/importFromRegistry.ts index ed123714..ad37b469 100644 --- a/src/commands/importFromRegistry.ts +++ b/src/commands/importFromRegistry.ts @@ -2,7 +2,7 @@ import * as vscode from "vscode"; import { ServerManagerAuthenticationProvider } from "../authenticationProvider"; // To avoid overhead querying the registry, cache responses (each time the command is run) -const regQueryCache = new Map(); +const regQueryCache = new Map(); export async function importFromRegistry(secretStorage: vscode.SecretStorage, scope?: vscode.ConfigurationScope) { const config = vscode.workspace.getConfiguration("intersystems", scope); @@ -291,7 +291,7 @@ function getStringRegKey(cmd: any, hive: string, path: string, key: string): str if (!regData.data) { return undefined; } - regQueryCache.set(queryPath, { data: regData.data }); + regQueryCache.set(queryPath, regData); const results = regData.data.split("\r\n") // Result lines from reg query are 4-space-delimited .map((line) => line.split(" "))