Mark array params in vscode.d.ts readonly (#124599)

I recently ran into an issue where I was trying to call showQuickPick with a readonly array. This is currently not allowed, even though `showQuickPick` never mutates the input

This change marks a few places in `vscode.d.ts` where we take arrays as parameters as `readonly []`. It also caught a potential bug with`getSession` modifying the input array
This commit is contained in:
Matt Bierner
2021-05-25 18:18:47 -07:00
committed by GitHub
parent 7d50ce2061
commit 24a23a8ea0
5 changed files with 23 additions and 23 deletions

View File

@@ -219,7 +219,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
})();
const authentication: typeof vscode.authentication = {
getSession(providerId: string, scopes: string[], options?: vscode.AuthenticationGetSessionOptions) {
getSession(providerId: string, scopes: readonly string[], options?: vscode.AuthenticationGetSessionOptions) {
return extHostAuthentication.getSession(extension, providerId, scopes, options as any);
},
get onDidChangeSessions(): Event<vscode.AuthenticationSessionsChangeEvent> {
@@ -998,10 +998,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
stopDebugging(session?: vscode.DebugSession) {
return extHostDebugService.stopDebugging(session);
},
addBreakpoints(breakpoints: vscode.Breakpoint[]) {
addBreakpoints(breakpoints: readonly vscode.Breakpoint[]) {
return extHostDebugService.addBreakpoints(breakpoints);
},
removeBreakpoints(breakpoints: vscode.Breakpoint[]) {
removeBreakpoints(breakpoints: readonly vscode.Breakpoint[]) {
return extHostDebugService.removeBreakpoints(breakpoints);
},
asDebugSourceUri(source: vscode.DebugProtocolSource, session?: vscode.DebugSession): vscode.Uri {