From b644486174af0aefec595f23cf3e42a09bf7688a Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 16 Sep 2019 08:33:49 +0200 Subject: [PATCH] debt - a bit more strict init --- src/vs/code/browser/workbench/workbench.ts | 2 +- .../electron-browser/lifecycleService.ts | 2 +- src/vs/platform/workspace/common/workspace.ts | 4 ++-- .../workspacesMainService.test.ts | 16 +++------------- src/vs/workbench/browser/legacyLayout.ts | 18 +++++++++--------- .../workbench/contrib/remote/browser/remote.ts | 4 ++-- .../contrib/watermark/browser/watermark.ts | 2 +- 7 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/vs/code/browser/workbench/workbench.ts b/src/vs/code/browser/workbench/workbench.ts index 3cbcc5ae3b87f..ed00f5003a97d 100644 --- a/src/vs/code/browser/workbench/workbench.ts +++ b/src/vs/code/browser/workbench/workbench.ts @@ -24,7 +24,7 @@ class LocalStorageCredentialsProvider implements ICredentialsProvider { static readonly CREDENTIALS_OPENED_KEY = 'credentials.provider'; - private _credentials: ICredential[]; + private _credentials!: ICredential[]; private get credentials(): ICredential[] { if (!this._credentials) { try { diff --git a/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts b/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts index 0146a3b60ac64..8505d978cd69f 100644 --- a/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts +++ b/src/vs/platform/lifecycle/electron-browser/lifecycleService.ts @@ -19,7 +19,7 @@ export class LifecycleService extends AbstractLifecycleService { _serviceBrand: undefined; - private shutdownReason: ShutdownReason; + private shutdownReason: ShutdownReason | undefined; constructor( @INotificationService private readonly notificationService: INotificationService, diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index 07cf7b302121d..894c7d336428d 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -143,7 +143,7 @@ export interface IWorkspaceFolder extends IWorkspaceFolderData { export class Workspace implements IWorkspace { private _foldersMap: TernarySearchTree = TernarySearchTree.forPaths(); - private _folders: WorkspaceFolder[]; + private _folders!: WorkspaceFolder[]; constructor( private _id: string, @@ -265,4 +265,4 @@ export function toWorkspaceFolders(configuredFolders: IStoredWorkspaceFolder[], } } return result; -} \ No newline at end of file +} diff --git a/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts b/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts index 2cad1c5f1f4b8..7a4c711c604d6 100644 --- a/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts +++ b/src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts @@ -11,7 +11,7 @@ import * as pfs from 'vs/base/node/pfs'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv'; import { WorkspacesMainService, IStoredWorkspace } from 'vs/platform/workspaces/electron-main/workspacesMainService'; -import { WORKSPACE_EXTENSION, IWorkspaceIdentifier, IRawFileWorkspaceFolder, IWorkspaceFolderCreationData, IRawUriWorkspaceFolder, rewriteWorkspaceFileForNewLocation } from 'vs/platform/workspaces/common/workspaces'; +import { WORKSPACE_EXTENSION, IRawFileWorkspaceFolder, IWorkspaceFolderCreationData, IRawUriWorkspaceFolder, rewriteWorkspaceFileForNewLocation } from 'vs/platform/workspaces/common/workspaces'; import { NullLogService } from 'vs/platform/log/common/log'; import { URI } from 'vs/base/common/uri'; import { getRandomTestPath } from 'vs/base/test/node/testUtils'; @@ -29,16 +29,6 @@ suite('WorkspacesMainService', () => { } } - class TestWorkspacesMainService extends WorkspacesMainService { - public deleteWorkspaceCall: IWorkspaceIdentifier; - - public deleteUntitledWorkspaceSync(workspace: IWorkspaceIdentifier): void { - this.deleteWorkspaceCall = workspace; - - super.deleteUntitledWorkspaceSync(workspace); - } - } - function createWorkspace(folders: string[], names?: string[]) { return service.createUntitledWorkspace(folders.map((folder, index) => ({ uri: URI.file(folder), name: names ? names[index] : undefined } as IWorkspaceFolderCreationData))); } @@ -50,10 +40,10 @@ suite('WorkspacesMainService', () => { const environmentService = new TestEnvironmentService(parseArgs(process.argv, OPTIONS), process.execPath); const logService = new NullLogService(); - let service: TestWorkspacesMainService; + let service: WorkspacesMainService; setup(async () => { - service = new TestWorkspacesMainService(environmentService, logService); + service = new WorkspacesMainService(environmentService, logService); // Delete any existing backups completely and then re-create it. await pfs.rimraf(untitledWorkspacesHomePath, pfs.RimRafMode.MOVE); diff --git a/src/vs/workbench/browser/legacyLayout.ts b/src/vs/workbench/browser/legacyLayout.ts index 049d9bf95d6da..c7ffa11b11f39 100644 --- a/src/vs/workbench/browser/legacyLayout.ts +++ b/src/vs/workbench/browser/legacyLayout.ts @@ -43,20 +43,20 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa private static readonly sashYHeightSettingsKey = 'workbench.panel.height'; private static readonly panelSizeBeforeMaximizedKey = 'workbench.panel.sizeBeforeMaximized'; - private workbenchSize: Dimension; + private workbenchSize!: Dimension; private sashXOne: Sash; private sashXTwo: Sash; private sashY: Sash; - private _sidebarWidth: number; - private sidebarHeight: number; - private titlebarHeight: number; - private statusbarHeight: number; - private panelSizeBeforeMaximized: number; - private panelMaximized: boolean; - private _panelHeight: number; - private _panelWidth: number; + private _sidebarWidth!: number; + private sidebarHeight!: number; + private titlebarHeight!: number; + private statusbarHeight!: number; + private panelSizeBeforeMaximized!: number; + private panelMaximized!: boolean; + private _panelHeight!: number; + private _panelWidth!: number; constructor( private parent: HTMLElement, diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts index 6d3e2d53b4c1e..df1df4650af1d 100644 --- a/src/vs/workbench/contrib/remote/browser/remote.ts +++ b/src/vs/workbench/contrib/remote/browser/remote.ts @@ -126,7 +126,7 @@ class HelpDataSource implements IAsyncDataSource { } getChildren(element: any) { - if (element instanceof HelpModel) { + if (element instanceof HelpModel && element.items) { return element.items; } @@ -201,7 +201,7 @@ class IssueReporterItem implements IHelpItem { } class HelpModel { - items: IHelpItem[]; + items: IHelpItem[] | undefined; constructor( viewModel: IViewModel, diff --git a/src/vs/workbench/contrib/watermark/browser/watermark.ts b/src/vs/workbench/contrib/watermark/browser/watermark.ts index a18b827e544f6..e9a4d74f213bf 100644 --- a/src/vs/workbench/contrib/watermark/browser/watermark.ts +++ b/src/vs/workbench/contrib/watermark/browser/watermark.ts @@ -69,7 +69,7 @@ const folderEntries = [ const WORKBENCH_TIPS_ENABLED_KEY = 'workbench.tips.enabled'; export class WatermarkContribution extends Disposable implements IWorkbenchContribution { - private watermark: HTMLElement; + private watermark: HTMLElement | undefined; private watermarkDisposable = this._register(new DisposableStore()); private enabled: boolean; private workbenchState: WorkbenchState;