Marking that documents/workspaces arrays cannot be mutated

This commit is contained in:
Matt Bierner 2020-02-10 16:57:41 -08:00
parent 498deeb4bc
commit efb781e5be
4 changed files with 5 additions and 5 deletions

View file

@ -13,7 +13,7 @@ interface ExperimentalConfig {
}; };
} }
export function getCustomDataPathsInAllWorkspaces(workspaceFolders: WorkspaceFolder[] | undefined): string[] { export function getCustomDataPathsInAllWorkspaces(workspaceFolders: readonly WorkspaceFolder[] | undefined): string[] {
const dataPaths: string[] = []; const dataPaths: string[] = [];
if (!workspaceFolders) { if (!workspaceFolders) {

View file

@ -13,7 +13,7 @@ interface ExperimentalConfig {
}; };
} }
export function getCustomDataPathsInAllWorkspaces(workspaceFolders: WorkspaceFolder[] | undefined): string[] { export function getCustomDataPathsInAllWorkspaces(workspaceFolders: readonly WorkspaceFolder[] | undefined): string[] {
const dataPaths: string[] = []; const dataPaths: string[] = [];
if (!workspaceFolders) { if (!workspaceFolders) {

View file

@ -634,7 +634,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
} }
public getWorkspaceRootForResource(resource: vscode.Uri): string | undefined { public getWorkspaceRootForResource(resource: vscode.Uri): string | undefined {
const roots = vscode.workspace.workspaceFolders; const roots = vscode.workspace.workspaceFolders ? Array.from(vscode.workspace.workspaceFolders) : undefined;
if (!roots || !roots.length) { if (!roots || !roots.length) {
return undefined; return undefined;
} }

4
src/vs/vscode.d.ts vendored
View file

@ -8435,7 +8435,7 @@ declare module 'vscode' {
* List of workspace folders or `undefined` when no folder is open. * List of workspace folders or `undefined` when no folder is open.
* *Note* that the first entry corresponds to the value of `rootPath`. * *Note* that the first entry corresponds to the value of `rootPath`.
*/ */
export const workspaceFolders: WorkspaceFolder[] | undefined; export const workspaceFolders: ReadonlyArray<WorkspaceFolder> | undefined;
/** /**
* The name of the workspace. `undefined` when no folder * The name of the workspace. `undefined` when no folder
@ -8609,7 +8609,7 @@ declare module 'vscode' {
/** /**
* All text documents currently known to the system. * All text documents currently known to the system.
*/ */
export const textDocuments: TextDocument[]; export const textDocuments: ReadonlyArray<TextDocument>;
/** /**
* Opens a document. Will return early if this document is already open. Otherwise * Opens a document. Will return early if this document is already open. Otherwise