Skip to content

Commit 8baeed4

Browse files
authored
Strengthen some types (microsoft#186190)
Also suppresses a scanner warning
1 parent fb4f736 commit 8baeed4

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

src/vs/workbench/api/browser/mainThreadCLICommands.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { IExtensionManifestPropertiesService } from 'vs/workbench/services/exten
2626

2727
// this class contains the commands that the CLI server is reying on
2828

29-
CommandsRegistry.registerCommand('_remoteCLI.openExternal', function (accessor: ServicesAccessor, uri: UriComponents | string) {
29+
CommandsRegistry.registerCommand('_remoteCLI.openExternal', function (accessor: ServicesAccessor, uri: UriComponents | string): Promise<boolean> {
3030
const openerService = accessor.get(IOpenerService);
3131
return openerService.open(isString(uri) ? uri : URI.revive(uri), { openExternal: true, allowTunneling: true });
3232
});
@@ -39,9 +39,9 @@ CommandsRegistry.registerCommand('_remoteCLI.windowOpen', function (accessor: Se
3939
return commandService.executeCommand('_files.windowOpen', toOpen, options);
4040
});
4141

42-
CommandsRegistry.registerCommand('_remoteCLI.getSystemStatus', function (accessor: ServicesAccessor) {
42+
CommandsRegistry.registerCommand('_remoteCLI.getSystemStatus', function (accessor: ServicesAccessor): Promise<string | undefined> {
4343
const commandService = accessor.get(ICommandService);
44-
return commandService.executeCommand('_issues.getSystemStatus');
44+
return commandService.executeCommand<string>('_issues.getSystemStatus');
4545
});
4646

4747
interface ManageExtensionsArgs {
@@ -51,8 +51,7 @@ interface ManageExtensionsArgs {
5151
force?: boolean;
5252
}
5353

54-
CommandsRegistry.registerCommand('_remoteCLI.manageExtensions', async function (accessor: ServicesAccessor, args: ManageExtensionsArgs) {
55-
54+
CommandsRegistry.registerCommand('_remoteCLI.manageExtensions', async function (accessor: ServicesAccessor, args: ManageExtensionsArgs): Promise<string | undefined> {
5655
const instantiationService = accessor.get(IInstantiationService);
5756
const extensionManagementServerService = accessor.get(IExtensionManagementServerService);
5857
const remoteExtensionManagementService = extensionManagementServerService.remoteExtensionManagementServer?.extensionManagementService;

src/vs/workbench/api/node/extHostCLIServer.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ export class CLIServerBase {
8080
}
8181

8282
private onRequest(req: http.IncomingMessage, res: http.ServerResponse): void {
83-
const sendResponse = (statusCode: number, returnObj: any) => {
83+
const sendResponse = (statusCode: number, returnObj: string | undefined) => {
8484
res.writeHead(statusCode, { 'content-type': 'application/json' });
85-
res.end(JSON.stringify(returnObj || null), (err?: any) => err && this.logService.error(err));
85+
res.end(JSON.stringify(returnObj || null), (err?: any) => err && this.logService.error(err)); // CodeQL [SM01524] Only the message portion of errors are passed in.
8686
};
8787

8888
const chunks: string[] = [];
@@ -91,7 +91,7 @@ export class CLIServerBase {
9191
req.on('end', async () => {
9292
try {
9393
const data: PipeCommand | any = JSON.parse(chunks.join(''));
94-
let returnObj;
94+
let returnObj: string | undefined;
9595
switch (data.type) {
9696
case 'open':
9797
returnObj = await this.open(data);
@@ -118,7 +118,7 @@ export class CLIServerBase {
118118
});
119119
}
120120

121-
private async open(data: OpenCommandPipeArgs): Promise<string> {
121+
private async open(data: OpenCommandPipeArgs): Promise<undefined> {
122122
const { fileURIs, folderURIs, forceNewWindow, diffMode, mergeMode, addMode, forceReuseWindow, gotoLineMode, waitMarkerFilePath, remoteAuthority } = data;
123123
const urisToOpen: IWindowOpenable[] = [];
124124
if (Array.isArray(folderURIs)) {
@@ -147,31 +147,29 @@ export class CLIServerBase {
147147
const preferNewWindow = !forceReuseWindow && !waitMarkerFileURI && !addMode;
148148
const windowOpenArgs: IOpenWindowOptions = { forceNewWindow, diffMode, mergeMode, addMode, gotoLineMode, forceReuseWindow, preferNewWindow, waitMarkerFileURI, remoteAuthority };
149149
this._commands.executeCommand('_remoteCLI.windowOpen', urisToOpen, windowOpenArgs);
150-
151-
return '';
152150
}
153151

154-
private async openExternal(data: OpenExternalCommandPipeArgs): Promise<any> {
152+
private async openExternal(data: OpenExternalCommandPipeArgs): Promise<undefined> {
155153
for (const uriString of data.uris) {
156154
const uri = URI.parse(uriString);
157155
const urioOpen = uri.scheme === 'file' ? uri : uriString; // workaround for #112577
158156
await this._commands.executeCommand('_remoteCLI.openExternal', urioOpen);
159157
}
160158
}
161159

162-
private async manageExtensions(data: ExtensionManagementPipeArgs): Promise<any> {
160+
private async manageExtensions(data: ExtensionManagementPipeArgs): Promise<string | undefined> {
163161
const toExtOrVSIX = (inputs: string[] | undefined) => inputs?.map(input => /\.vsix$/i.test(input) ? URI.parse(input) : input);
164162
const commandArgs = {
165163
list: data.list,
166164
install: toExtOrVSIX(data.install),
167165
uninstall: toExtOrVSIX(data.uninstall),
168166
force: data.force
169167
};
170-
return await this._commands.executeCommand('_remoteCLI.manageExtensions', commandArgs);
168+
return await this._commands.executeCommand<string | undefined>('_remoteCLI.manageExtensions', commandArgs);
171169
}
172170

173-
private async getStatus(data: StatusPipeArgs) {
174-
return await this._commands.executeCommand('_remoteCLI.getSystemStatus');
171+
private async getStatus(data: StatusPipeArgs): Promise<string | undefined> {
172+
return await this._commands.executeCommand<string | undefined>('_remoteCLI.getSystemStatus');
175173
}
176174

177175
dispose(): void {

0 commit comments

Comments
 (0)