diff --git a/src/vs/base/browser/ui/iconLabel/iconLabel.ts b/src/vs/base/browser/ui/iconLabel/iconLabel.ts index ec4a3c2f6de13a78b8eb8f43bbd705ec3717f145..b9fc41542342af34aad42b1f6f831d72c8576b7a 100644 --- a/src/vs/base/browser/ui/iconLabel/iconLabel.ts +++ b/src/vs/base/browser/ui/iconLabel/iconLabel.ts @@ -27,11 +27,11 @@ export interface IIconLabelValueOptions { } class FastLabelNode { - private disposed: boolean; - private _textContent: string; - private _className: string; - private _title: string; - private _empty: boolean; + private disposed: boolean | undefined; + private _textContent: string | undefined; + private _className: string | undefined; + private _title: string | undefined; + private _empty: boolean | undefined; constructor(private _element: HTMLElement) { } @@ -89,7 +89,7 @@ export class IconLabel extends Disposable { private domNode: FastLabelNode; private labelDescriptionContainer: FastLabelNode; private labelNode: FastLabelNode | HighlightedLabel; - private descriptionNode: FastLabelNode | HighlightedLabel; + private descriptionNode: FastLabelNode | HighlightedLabel | undefined; private descriptionNodeFactory: () => FastLabelNode | HighlightedLabel; constructor(container: HTMLElement, options?: IIconLabelCreationOptions) { diff --git a/src/vs/base/browser/ui/progressbar/progressbar.ts b/src/vs/base/browser/ui/progressbar/progressbar.ts index ce3a86a4d308331d2c290a68c1486c81660f8d9b..405bfe80c05454a77ecea894bef4cda90367d47a 100644 --- a/src/vs/base/browser/ui/progressbar/progressbar.ts +++ b/src/vs/base/browser/ui/progressbar/progressbar.ts @@ -36,8 +36,8 @@ const defaultOpts = { export class ProgressBar extends Disposable { private options: IProgressBarOptions; private workedVal: number; - private element: HTMLElement; - private bit: HTMLElement; + private element!: HTMLElement; + private bit!: HTMLElement; private totalWork: number | undefined; private progressBarBackground: Color | undefined; private showDelayedScheduler: RunOnceScheduler; @@ -232,4 +232,4 @@ export class ProgressBar extends Disposable { this.bit.style.backgroundColor = background; } } -} \ No newline at end of file +} diff --git a/src/vs/base/node/config.ts b/src/vs/base/node/config.ts index 4e12fd565ea5ef570acde382232da959d39d82df..6fac5849f9615d76a52b1d8a264912f89a3302cb 100644 --- a/src/vs/base/node/config.ts +++ b/src/vs/base/node/config.ts @@ -42,11 +42,11 @@ export interface IConfigOptions { * - configurable defaults */ export class ConfigWatcher extends Disposable implements IConfigWatcher { - private cache: T; - private parseErrors: json.ParseError[]; - private disposed: boolean; - private loaded: boolean; - private timeoutHandle: NodeJS.Timer | null; + private cache: T | undefined; + private parseErrors: json.ParseError[] | undefined; + private disposed: boolean | undefined; + private loaded: boolean | undefined; + private timeoutHandle: NodeJS.Timer | null | undefined; private readonly _onDidUpdateConfiguration: Emitter>; constructor(private _path: string, private options: IConfigOptions = { defaultConfig: Object.create(null), onError: error => console.error(error) }) { @@ -62,7 +62,7 @@ export class ConfigWatcher extends Disposable implements IConfigWatcher { } get hasParseErrors(): boolean { - return this.parseErrors && this.parseErrors.length > 0; + return !!this.parseErrors && this.parseErrors.length > 0; } get onDidUpdateConfiguration(): Event> { @@ -161,7 +161,7 @@ export class ConfigWatcher extends Disposable implements IConfigWatcher { if (!objects.equals(currentConfig, this.cache)) { this.updateCache(currentConfig); - this._onDidUpdateConfiguration.fire({ config: this.cache }); + this._onDidUpdateConfiguration.fire({ config: currentConfig }); } if (callback) { @@ -173,7 +173,7 @@ export class ConfigWatcher extends Disposable implements IConfigWatcher { getConfig(): T { this.ensureLoaded(); - return this.cache; + return this.cache!; } private ensureLoaded(): void { @@ -186,4 +186,4 @@ export class ConfigWatcher extends Disposable implements IConfigWatcher { this.disposed = true; super.dispose(); } -} \ No newline at end of file +} diff --git a/src/vs/base/parts/storage/node/storage.ts b/src/vs/base/parts/storage/node/storage.ts index edf313654aa0c6f42550371d45dfed02026990d5..85a3ef2d9acef25b90e0a49604e077be85b103ac 100644 --- a/src/vs/base/parts/storage/node/storage.ts +++ b/src/vs/base/parts/storage/node/storage.ts @@ -420,8 +420,8 @@ export class SQLiteStorageDatabase implements IStorageDatabase { } class SQLiteStorageDatabaseLogger { - private readonly logTrace: (msg: string) => void; - private readonly logError: (error: string | Error) => void; + private readonly logTrace: ((msg: string) => void) | undefined; + private readonly logError: ((error: string | Error) => void) | undefined; constructor(options?: ISQLiteStorageDatabaseLoggingOptions) { if (options && typeof options.logTrace === 'function') { diff --git a/src/vs/editor/contrib/find/findWidget.ts b/src/vs/editor/contrib/find/findWidget.ts index d35752a078dec61302a104af4caa5e93c86d2118..383f158c1dedc7c90f4ac5a0edf13df65c967b46 100644 --- a/src/vs/editor/contrib/find/findWidget.ts +++ b/src/vs/editor/contrib/find/findWidget.ts @@ -111,7 +111,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas private readonly _notificationService: INotificationService; private _domNode!: HTMLElement; - private _cachedHeight: number | null; + private _cachedHeight: number | null = null; private _findInput!: FindInput; private _replaceInput!: ReplaceInput; diff --git a/src/vs/platform/configuration/common/configurationModels.ts b/src/vs/platform/configuration/common/configurationModels.ts index 373a2e1b0861f5c6b9fa07fe0bc4d4603a9b5bfc..c4749186815203c4d1290da7776a847c6da11f88 100644 --- a/src/vs/platform/configuration/common/configurationModels.ts +++ b/src/vs/platform/configuration/common/configurationModels.ts @@ -441,7 +441,7 @@ export class Configuration { return this._defaultConfiguration; } - private _userConfiguration: ConfigurationModel | null; + private _userConfiguration: ConfigurationModel | null = null; get userConfiguration(): ConfigurationModel { if (!this._userConfiguration) { this._userConfiguration = this._remoteUserConfiguration.isEmpty() ? this._localUserConfiguration : this._localUserConfiguration.merge(this._remoteUserConfiguration); diff --git a/src/vs/platform/contextview/browser/contextMenuHandler.ts b/src/vs/platform/contextview/browser/contextMenuHandler.ts index 8ab9ccc2d824bd7978fb73add2690ea619441aad..921a5f810a51020460e16dcfa3df11809d4a9079 100644 --- a/src/vs/platform/contextview/browser/contextMenuHandler.ts +++ b/src/vs/platform/contextview/browser/contextMenuHandler.ts @@ -24,8 +24,8 @@ export interface IContextMenuHandlerOptions { } export class ContextMenuHandler { - private focusToReturn: HTMLElement; - private block: HTMLElement | null; + private focusToReturn: HTMLElement | null = null; + private block: HTMLElement | null = null; private options: IContextMenuHandlerOptions = { blockMouse: true }; constructor( diff --git a/src/vs/platform/files/node/diskFileSystemProvider.ts b/src/vs/platform/files/node/diskFileSystemProvider.ts index 12d5847389d934d5c67410b80082c87288ead30b..d66ef03839cdacc02c8548579f53a394ed73dbee 100644 --- a/src/vs/platform/files/node/diskFileSystemProvider.ts +++ b/src/vs/platform/files/node/diskFileSystemProvider.ts @@ -38,7 +38,7 @@ export class DiskFileSystemProvider extends Disposable implements IFileSystemPro onDidChangeCapabilities: Event = Event.None; - protected _capabilities: FileSystemProviderCapabilities; + protected _capabilities: FileSystemProviderCapabilities | undefined; get capabilities(): FileSystemProviderCapabilities { if (!this._capabilities) { this._capabilities = diff --git a/src/vs/platform/files/node/watcher/nodejs/watcherService.ts b/src/vs/platform/files/node/watcher/nodejs/watcherService.ts index 58c4a327734bf8ee1302c8bb3ef73c25bcad626c..b2bf3498400f181434d890342f09a38c28b18d5d 100644 --- a/src/vs/platform/files/node/watcher/nodejs/watcherService.ts +++ b/src/vs/platform/files/node/watcher/nodejs/watcherService.ts @@ -13,7 +13,7 @@ import { ThrottledDelayer } from 'vs/base/common/async'; import { join, basename } from 'vs/base/common/path'; export class FileWatcher extends Disposable { - private isDisposed: boolean; + private isDisposed: boolean | undefined; private fileChangesDelayer: ThrottledDelayer = this._register(new ThrottledDelayer(CHANGE_BUFFER_DELAY * 2 /* sync on delay from underlying library */)); private fileChangesBuffer: IDiskFileChange[] = []; @@ -125,4 +125,4 @@ export class FileWatcher extends Disposable { super.dispose(); } -} \ No newline at end of file +} diff --git a/src/vs/platform/files/node/watcher/nsfw/nsfwWatcherService.ts b/src/vs/platform/files/node/watcher/nsfw/nsfwWatcherService.ts index a9db893575b7bdcac515202bdb3342b71ffd4397..916a04920776f64c6e158d8eebac904347181e5c 100644 --- a/src/vs/platform/files/node/watcher/nsfw/nsfwWatcherService.ts +++ b/src/vs/platform/files/node/watcher/nsfw/nsfwWatcherService.ts @@ -36,8 +36,8 @@ export class NsfwWatcherService implements IWatcherService { private static readonly FS_EVENT_DELAY = 50; // aggregate and only emit events when changes have stopped for this duration (in ms) private _pathWatchers: { [watchPath: string]: IPathWatcher } = {}; - private _verboseLogging: boolean; - private enospcErrorLogged: boolean; + private _verboseLogging: boolean | undefined; + private enospcErrorLogged: boolean | undefined; private _onWatchEvent = new Emitter(); readonly onWatchEvent = this._onWatchEvent.event; diff --git a/src/vs/platform/files/node/watcher/nsfw/watcherService.ts b/src/vs/platform/files/node/watcher/nsfw/watcherService.ts index 8b4673d193426cd2a8733feaca00ca9b234f2c80..7a32b3e04b1acec49294fe0dad2747dc7edaa685 100644 --- a/src/vs/platform/files/node/watcher/nsfw/watcherService.ts +++ b/src/vs/platform/files/node/watcher/nsfw/watcherService.ts @@ -12,9 +12,10 @@ import { IWatcherRequest } from 'vs/platform/files/node/watcher/nsfw/watcher'; import { getPathFromAmdModule } from 'vs/base/common/amd'; export class FileWatcher extends Disposable { + private static readonly MAX_RESTARTS = 5; - private service: WatcherChannelClient; + private service: WatcherChannelClient | undefined; private isDisposed: boolean; private restartCounter: number; @@ -77,7 +78,7 @@ export class FileWatcher extends Disposable { setVerboseLogging(verboseLogging: boolean): void { this.verboseLogging = verboseLogging; - if (!this.isDisposed) { + if (!this.isDisposed && this.service) { this.service.setVerboseLogging(verboseLogging); } } @@ -89,7 +90,9 @@ export class FileWatcher extends Disposable { setFolders(folders: IWatcherRequest[]): void { this.folders = folders; - this.service.setRoots(folders); + if (this.service) { + this.service.setRoots(folders); + } } dispose(): void { diff --git a/src/vs/platform/files/node/watcher/unix/chokidarWatcherService.ts b/src/vs/platform/files/node/watcher/unix/chokidarWatcherService.ts index a03e76ba178531c08f6ad538a6d74640f081afd3..5976158610b42ef18943eeec29d03a80e75e135e 100644 --- a/src/vs/platform/files/node/watcher/unix/chokidarWatcherService.ts +++ b/src/vs/platform/files/node/watcher/unix/chokidarWatcherService.ts @@ -37,11 +37,11 @@ export class ChokidarWatcherService implements IWatcherService { private _pollingInterval?: number; private _usePolling?: boolean; - private _verboseLogging: boolean; + private _verboseLogging: boolean | undefined; - private spamCheckStartTime: number; - private spamWarningLogged: boolean; - private enospcErrorLogged: boolean; + private spamCheckStartTime: number | undefined; + private spamWarningLogged: boolean | undefined; + private enospcErrorLogged: boolean | undefined; private _onWatchEvent = new Emitter(); readonly onWatchEvent = this._onWatchEvent.event; @@ -231,7 +231,7 @@ export class ChokidarWatcherService implements IWatcherService { if (undeliveredFileEvents.length === 0) { this.spamWarningLogged = false; this.spamCheckStartTime = now; - } else if (!this.spamWarningLogged && this.spamCheckStartTime + ChokidarWatcherService.EVENT_SPAM_WARNING_THRESHOLD < now) { + } else if (!this.spamWarningLogged && typeof this.spamCheckStartTime === 'number' && this.spamCheckStartTime + ChokidarWatcherService.EVENT_SPAM_WARNING_THRESHOLD < now) { this.spamWarningLogged = true; this.warn(`Watcher is busy catching up with ${undeliveredFileEvents.length} file changes in 60 seconds. Latest changed path is "${event.path}"`); } diff --git a/src/vs/platform/files/node/watcher/unix/watcherService.ts b/src/vs/platform/files/node/watcher/unix/watcherService.ts index 18d55aec1d8bb153744956584109f92d5326f430..5fd8d4e39aa97652413f433e09297656e213a22d 100644 --- a/src/vs/platform/files/node/watcher/unix/watcherService.ts +++ b/src/vs/platform/files/node/watcher/unix/watcherService.ts @@ -16,7 +16,7 @@ export class FileWatcher extends Disposable { private isDisposed: boolean; private restartCounter: number; - private service: WatcherChannelClient; + private service: WatcherChannelClient | undefined; constructor( private folders: IWatcherRequest[], @@ -81,13 +81,18 @@ export class FileWatcher extends Disposable { setVerboseLogging(verboseLogging: boolean): void { this.verboseLogging = verboseLogging; - this.service.setVerboseLogging(verboseLogging); + + if (this.service) { + this.service.setVerboseLogging(verboseLogging); + } } setFolders(folders: IWatcherRequest[]): void { this.folders = folders; - this.service.setRoots(folders); + if (this.service) { + this.service.setRoots(folders); + } } dispose(): void { diff --git a/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts b/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts index bdecf24ff13ba319ed15d29bd4cb00f666dfb544..72f2d7c124f319be76ff27293a746e362c64d4ed 100644 --- a/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts +++ b/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts @@ -139,10 +139,10 @@ export class LifecycleService extends Disposable implements ILifecycleService { private oneTimeListenerTokenGenerator = 0; private windowCounter = 0; - private pendingQuitPromise: Promise | null; - private pendingQuitPromiseResolve: { (veto: boolean): void } | null; + private pendingQuitPromise: Promise | null = null; + private pendingQuitPromiseResolve: { (veto: boolean): void } | null = null; - private pendingWillShutdownPromise: Promise | null; + private pendingWillShutdownPromise: Promise | null = null; private _quitRequested = false; get quitRequested(): boolean { return this._quitRequested; } diff --git a/src/vs/platform/storage/node/storageIpc.ts b/src/vs/platform/storage/node/storageIpc.ts index ac5926cc2497cc486f90cbc7889a4779a20a3c93..f74005b5ed4b1fdbdc9ef5b0bf4fdb47cc7f6d38 100644 --- a/src/vs/platform/storage/node/storageIpc.ts +++ b/src/vs/platform/storage/node/storageIpc.ts @@ -152,7 +152,7 @@ export class GlobalStorageDatabaseChannelClient extends Disposable implements IS private readonly _onDidChangeItemsExternal: Emitter = this._register(new Emitter()); readonly onDidChangeItemsExternal: Event = this._onDidChangeItemsExternal.event; - private onDidChangeItemsOnMainListener: IDisposable; + private onDidChangeItemsOnMainListener: IDisposable | undefined; constructor(private channel: IChannel) { super(); diff --git a/src/vs/platform/storage/node/storageMainService.ts b/src/vs/platform/storage/node/storageMainService.ts index 95274a2350b961f99cba372952756456dd3121f0..70cdeef730ddfe8bddcb90e548cf9977bf71aafc 100644 --- a/src/vs/platform/storage/node/storageMainService.ts +++ b/src/vs/platform/storage/node/storageMainService.ts @@ -99,7 +99,7 @@ export class StorageMainService extends Disposable implements IStorageMainServic private storage: IStorage; - private initializePromise: Promise; + private initializePromise: Promise | undefined; constructor( @ILogService private readonly logService: ILogService, diff --git a/src/vs/workbench/api/browser/mainThreadDebugService.ts b/src/vs/workbench/api/browser/mainThreadDebugService.ts index 2f0f5283bfd219f1c3001554e4c3eba7d3f1fee0..fc830d3ddc2fa876371ebb071bdc54173594f681 100644 --- a/src/vs/workbench/api/browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/browser/mainThreadDebugService.ts @@ -21,7 +21,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb private readonly _proxy: ExtHostDebugServiceShape; private readonly _toDispose = new DisposableStore(); - private _breakpointEventsActive: boolean; + private _breakpointEventsActive: boolean | undefined; private readonly _debugAdapters: Map; private _debugAdaptersHandleCounter = 1; private readonly _debugConfigurationProviders: Map; diff --git a/src/vs/workbench/browser/part.ts b/src/vs/workbench/browser/part.ts index c78ad168cb7627131864d48cc80fec0d0505b59f..da759cd76e11232850028a04d25d7e868ebdfd8a 100644 --- a/src/vs/workbench/browser/part.ts +++ b/src/vs/workbench/browser/part.ts @@ -33,8 +33,8 @@ export abstract class Part extends Component implements ISerializableView { get dimension(): Dimension { return this._dimension; } private parent: HTMLElement; - private titleArea: HTMLElement | null; - private contentArea: HTMLElement | null; + private titleArea: HTMLElement | null = null; + private contentArea: HTMLElement | null = null; private partLayout: PartLayout; constructor( diff --git a/src/vs/workbench/browser/parts/editor/baseEditor.ts b/src/vs/workbench/browser/parts/editor/baseEditor.ts index 53f5fa55ce7b7ca8def625f9c146b8189dabac1c..8bbf5ca5b64c0625cf2dd5d0bdbce5b6b3a4a23c 100644 --- a/src/vs/workbench/browser/parts/editor/baseEditor.ts +++ b/src/vs/workbench/browser/parts/editor/baseEditor.ts @@ -41,8 +41,8 @@ export abstract class BaseEditor extends Panel implements IEditor { readonly onDidSizeConstraintsChange: Event<{ width: number; height: number; } | undefined> = Event.None; - protected _input: EditorInput | null; - protected _options: EditorOptions | null; + protected _input: EditorInput | null = null; + protected _options: EditorOptions | null = null; private _group?: IEditorGroup; @@ -172,7 +172,7 @@ interface MapGroupToMemento { } export class EditorMemento implements IEditorMemento { - private cache: LRUCache>; + private cache: LRUCache> | undefined; private cleanedUp = false; constructor( diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index 162e7f25cb8edb27359785d18bd70e2ef32335fc..915c264daea206a4013516ca214d346a4edec3d6 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -229,7 +229,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(ChangeEOLAction, Chang registry.registerWorkbenchAction(new SyncActionDescriptor(ChangeEncodingAction, ChangeEncodingAction.ID, ChangeEncodingAction.LABEL), 'Change File Encoding'); export class QuickOpenActionContributor extends ActionBarContributor { - private openToSideActionInstance: OpenToSideFromQuickOpenAction; + private openToSideActionInstance: OpenToSideFromQuickOpenAction | undefined; constructor(@IInstantiationService private readonly instantiationService: IInstantiationService) { super(); diff --git a/src/vs/workbench/browser/parts/editor/editorCommands.ts b/src/vs/workbench/browser/parts/editor/editorCommands.ts index 638c44e147eb7c96754e4830924906b2f0ec07d9..654a9c966505da0ac3b4576ff9feb6f75f90ccdd 100644 --- a/src/vs/workbench/browser/parts/editor/editorCommands.ts +++ b/src/vs/workbench/browser/parts/editor/editorCommands.ts @@ -263,7 +263,10 @@ function registerDiffEditorCommands(): void { const candidates = [editorService.activeControl, ...editorService.visibleControls].filter(e => e instanceof TextDiffEditor); if (candidates.length > 0) { - next ? (candidates[0]).getDiffNavigator().next() : (candidates[0]).getDiffNavigator().previous(); + const navigator = (candidates[0]).getDiffNavigator(); + if (navigator) { + next ? navigator.next() : navigator.previous(); + } } } diff --git a/src/vs/workbench/browser/parts/editor/editorControl.ts b/src/vs/workbench/browser/parts/editor/editorControl.ts index 9b59e8e38f7ec062ea91e65b8803a1fca69acdfa..9f29b3a652392baaed782373d7a89b567b913874 100644 --- a/src/vs/workbench/browser/parts/editor/editorControl.ts +++ b/src/vs/workbench/browser/parts/editor/editorControl.ts @@ -35,11 +35,11 @@ export class EditorControl extends Disposable { private _onDidSizeConstraintsChange = this._register(new Emitter<{ width: number; height: number; } | undefined>()); get onDidSizeConstraintsChange(): Event<{ width: number; height: number; } | undefined> { return this._onDidSizeConstraintsChange.event; } - private _activeControl: BaseEditor | null; + private _activeControl: BaseEditor | null = null; private controls: BaseEditor[] = []; private readonly activeControlDisposables = this._register(new DisposableStore()); - private dimension: Dimension; + private dimension: Dimension | undefined; private editorOperation: LongRunningOperation; constructor( diff --git a/src/vs/workbench/browser/parts/editor/editorDropTarget.ts b/src/vs/workbench/browser/parts/editor/editorDropTarget.ts index 97cabc264b64ce9aced9e0f92e44e27b59ae2aff..2113a4e7c501f1bea22654c5d02d7c5f3d678d1f 100644 --- a/src/vs/workbench/browser/parts/editor/editorDropTarget.ts +++ b/src/vs/workbench/browser/parts/editor/editorDropTarget.ts @@ -25,11 +25,11 @@ class DropOverlay extends Themable { private static OVERLAY_ID = 'monaco-workbench-editor-drop-overlay'; - private container: HTMLElement; - private overlay: HTMLElement; + private container!: HTMLElement; + private overlay!: HTMLElement; - private currentDropOperation?: IDropOperation; - private _disposed: boolean; + private currentDropOperation: IDropOperation | undefined; + private _disposed: boolean | undefined; private cleanupOverlayScheduler: RunOnceScheduler; @@ -50,7 +50,7 @@ class DropOverlay extends Themable { } get disposed(): boolean { - return this._disposed; + return !!this._disposed; } private create(): void { diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index 7b791423c5eb90223cdc3487715673b7f2fba3c5..3b69c58802d8caea81bedde8e76671f500e6dd49 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -40,7 +40,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor { static readonly ID = TEXT_DIFF_EDITOR_ID; - private diffNavigator: DiffNavigator; + private diffNavigator: DiffNavigator | undefined; private readonly diffNavigatorDisposables = this._register(new DisposableStore()); constructor( @@ -257,7 +257,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor { super.clearInput(); } - getDiffNavigator(): DiffNavigator { + getDiffNavigator(): DiffNavigator | undefined { return this.diffNavigator; } diff --git a/src/vs/workbench/browser/parts/editor/titleControl.ts b/src/vs/workbench/browser/parts/editor/titleControl.ts index 967a587184fb1436674d811317fb82af13a55fbe..97d9bb6aee112ae995f104cd22fc877ba20f755f 100644 --- a/src/vs/workbench/browser/parts/editor/titleControl.ts +++ b/src/vs/workbench/browser/parts/editor/titleControl.ts @@ -57,7 +57,7 @@ export abstract class TitleControl extends Themable { private currentPrimaryEditorActionIds: string[] = []; private currentSecondaryEditorActionIds: string[] = []; - protected editorActionsToolbar: ToolBar; + private editorActionsToolbar: ToolBar; private resourceContext: ResourceContextKey; private editorPinnedContext: IContextKey; diff --git a/src/vs/workbench/browser/parts/views/viewsViewlet.ts b/src/vs/workbench/browser/parts/views/viewsViewlet.ts index 3100093436c71ec047c6d328381457329673ca27..6413ac3173fab4e2bff5a437bea638e49b30094a 100644 --- a/src/vs/workbench/browser/parts/views/viewsViewlet.ts +++ b/src/vs/workbench/browser/parts/views/viewsViewlet.ts @@ -39,7 +39,7 @@ export abstract class ViewContainerViewlet extends PanelViewlet implements IView private readonly viewletState: MementoObject; private didLayout = false; - private dimension: DOM.Dimension; + private dimension: DOM.Dimension | undefined; private areExtensionsReady: boolean = false; private readonly visibleViewsCountFromCache: number | undefined; diff --git a/src/vs/workbench/browser/web.simpleservices.ts b/src/vs/workbench/browser/web.simpleservices.ts index d2729c92609ee0b7073599e5d2787f134054ed09..caf44465e739f51a76fb37755552c7999958388d 100644 --- a/src/vs/workbench/browser/web.simpleservices.ts +++ b/src/vs/workbench/browser/web.simpleservices.ts @@ -41,7 +41,7 @@ export class SimpleUpdateService implements IUpdateService { _serviceBrand: undefined; onStateChange = Event.None; - state: State; + state!: State; checkForUpdates(context: any): Promise { return Promise.resolve(undefined); diff --git a/src/vs/workbench/common/editor/diffEditorInput.ts b/src/vs/workbench/common/editor/diffEditorInput.ts index 477d54e754c15e593ea8c526ee6c423b105ba1fe..bd2b9376854cb498108cba2af9f16ee2d3b8ff44 100644 --- a/src/vs/workbench/common/editor/diffEditorInput.ts +++ b/src/vs/workbench/common/editor/diffEditorInput.ts @@ -16,7 +16,7 @@ export class DiffEditorInput extends SideBySideEditorInput { static readonly ID = 'workbench.editors.diffEditorInput'; - private cachedModel: DiffEditorModel | null; + private cachedModel: DiffEditorModel | null = null; constructor(name: string, description: string | undefined, original: EditorInput, modified: EditorInput, private readonly forceOpenAsBinary?: boolean) { super(name, description, original, modified); @@ -86,4 +86,4 @@ export class DiffEditorInput extends SideBySideEditorInput { super.dispose(); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/common/editor/editorGroup.ts b/src/vs/workbench/common/editor/editorGroup.ts index 5b207d4a79db9e69b95454feb1f22628c785812e..a8b139501bea43baff1944ff1866978f843950d0 100644 --- a/src/vs/workbench/common/editor/editorGroup.ts +++ b/src/vs/workbench/common/editor/editorGroup.ts @@ -94,8 +94,8 @@ export class EditorGroup extends Disposable { private mru: EditorInput[] = []; private mapResourceToEditorCount: ResourceMap = new ResourceMap(); - private preview: EditorInput | null; // editor in preview state - private active: EditorInput | null; // editor in active state + private preview: EditorInput | null = null; // editor in preview state + private active: EditorInput | null = null; // editor in active state private editorOpenPositioning: 'left' | 'right' | 'first' | 'last'; private focusRecentEditorAfterClose: boolean; diff --git a/src/vs/workbench/common/editor/resourceEditorInput.ts b/src/vs/workbench/common/editor/resourceEditorInput.ts index 8ea157dffc2d5594ec516c97d1251e45bc09fd40..1d7712d1c4e9041981dbd49a0139a8c01e8dc8ac 100644 --- a/src/vs/workbench/common/editor/resourceEditorInput.ts +++ b/src/vs/workbench/common/editor/resourceEditorInput.ts @@ -17,8 +17,8 @@ export class ResourceEditorInput extends EditorInput implements IModeSupport { static readonly ID: string = 'workbench.editors.resourceEditorInput'; - private cachedModel: ResourceEditorModel | null; - private modelReference: Promise> | null; + private cachedModel: ResourceEditorModel | null = null; + private modelReference: Promise> | null = null; constructor( private name: string, diff --git a/src/vs/workbench/common/editor/textDiffEditorModel.ts b/src/vs/workbench/common/editor/textDiffEditorModel.ts index 1f48d92db2909bf075bb6c127f614b29aeac74d8..7f359e23f8add830d0f64432238ceb0ae3bb91f4 100644 --- a/src/vs/workbench/common/editor/textDiffEditorModel.ts +++ b/src/vs/workbench/common/editor/textDiffEditorModel.ts @@ -17,7 +17,7 @@ export class TextDiffEditorModel extends DiffEditorModel { protected readonly _originalModel: BaseTextEditorModel; protected readonly _modifiedModel: BaseTextEditorModel; - private _textDiffEditorModel: IDiffEditorModel | null; + private _textDiffEditorModel: IDiffEditorModel | null = null; constructor(originalModel: BaseTextEditorModel, modifiedModel: BaseTextEditorModel) { super(originalModel, modifiedModel); diff --git a/src/vs/workbench/common/editor/untitledEditorInput.ts b/src/vs/workbench/common/editor/untitledEditorInput.ts index 1a0af06b7a70b092d8e5ae0723040f9d97e8310d..adae5eddbd36b511ad59c160f4a59b22c84cc9d8 100644 --- a/src/vs/workbench/common/editor/untitledEditorInput.ts +++ b/src/vs/workbench/common/editor/untitledEditorInput.ts @@ -23,8 +23,8 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport static readonly ID: string = 'workbench.editors.untitledEditorInput'; - private cachedModel: UntitledEditorModel | null; - private modelResolve: Promise | null; + private cachedModel: UntitledEditorModel | null = null; + private modelResolve: Promise | null = null; private readonly _onDidModelChangeContent: Emitter = this._register(new Emitter()); readonly onDidModelChangeContent: Event = this._onDidModelChangeContent.event; diff --git a/src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts b/src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts index b95d1949bdf58c71823fd4b05d225a8218f15b53..e395251dc2992d116e62c0e1a25b7e87f45eb182 100644 --- a/src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts +++ b/src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts @@ -33,7 +33,7 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput { private forceOpenAs: ForceOpenAs = ForceOpenAs.None; - private textModelReference: Promise> | null; + private textModelReference: Promise> | null = null; private name: string; /** diff --git a/src/vs/workbench/contrib/markers/browser/markersModel.ts b/src/vs/workbench/contrib/markers/browser/markersModel.ts index 857e74d0caddfc9a4cd84d08fb7a1fd4ca40334f..9d0c046913affe7b2dc342621704be36df4d0fcb 100644 --- a/src/vs/workbench/contrib/markers/browser/markersModel.ts +++ b/src/vs/workbench/contrib/markers/browser/markersModel.ts @@ -58,7 +58,7 @@ export class Marker { get resource(): URI { return this.marker.resource; } get range(): IRange { return this.marker; } - private _lines: string[]; + private _lines: string[] | undefined; get lines(): string[] { if (!this._lines) { this._lines = this.marker.message.split(/\r\n|\r|\n/g); diff --git a/src/vs/workbench/contrib/preferences/common/preferencesContribution.ts b/src/vs/workbench/contrib/preferences/common/preferencesContribution.ts index 6e7f43ffcfabde4c9d98366e72658200f82062a3..cde13f2ab3203edb1f429053d86ecdf3e1e3432a 100644 --- a/src/vs/workbench/contrib/preferences/common/preferencesContribution.ts +++ b/src/vs/workbench/contrib/preferences/common/preferencesContribution.ts @@ -26,7 +26,7 @@ import { FOLDER_SETTINGS_PATH, IPreferencesService, USE_SPLIT_JSON_SETTING } fro const schemaRegistry = Registry.as(JSONContributionRegistry.Extensions.JSONContribution); export class PreferencesContribution implements IWorkbenchContribution { - private editorOpeningListener: IDisposable; + private editorOpeningListener: IDisposable | undefined; private settingsListener: IDisposable; constructor( diff --git a/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts b/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts index 3aa5697ed25988cbcc1f9bc6ea9580680fda0b71..7b7803814e0328ceeb8feffd205c61d870b6a4d5 100644 --- a/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts +++ b/src/vs/workbench/contrib/quickopen/browser/commandsHandler.ts @@ -217,8 +217,8 @@ class CommandPaletteEditorAction extends EditorAction { } abstract class BaseCommandEntry extends QuickOpenEntryGroup { - private description: string; - private alias: string; + private description: string | undefined; + private alias: string | undefined; private labelLowercase: string; private readonly keybindingAriaLabel?: string; @@ -258,7 +258,7 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup { return this.labelLowercase; } - getDescription(): string { + getDescription(): string | undefined { return this.description; } @@ -270,7 +270,7 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup { return this.keybinding; } - getDetail(): string { + getDetail(): string | undefined { return this.alias; } @@ -381,13 +381,13 @@ export class CommandsHandler extends QuickOpenHandler implements IDisposable { static readonly ID = 'workbench.picker.commands'; - private commandHistoryEnabled: boolean; + private commandHistoryEnabled: boolean | undefined; private readonly commandsHistory: CommandsHistory; private readonly disposables = new DisposableStore(); private readonly disposeOnClose = new DisposableStore(); - private waitedForExtensionsRegistered: boolean; + private waitedForExtensionsRegistered: boolean | undefined; constructor( @IEditorService private readonly editorService: IEditorService, diff --git a/src/vs/workbench/contrib/relauncher/common/relauncher.contribution.ts b/src/vs/workbench/contrib/relauncher/common/relauncher.contribution.ts index 2ec3089894f45646435ae91a4fdd590735a0cbc1..d691ca646e38359aa14f67e2d3203da5e133b0ec 100644 --- a/src/vs/workbench/contrib/relauncher/common/relauncher.contribution.ts +++ b/src/vs/workbench/contrib/relauncher/common/relauncher.contribution.ts @@ -29,15 +29,15 @@ interface IConfiguration extends IWindowsConfiguration { export class SettingsChangeRelauncher extends Disposable implements IWorkbenchContribution { - private titleBarStyle: 'native' | 'custom'; - private nativeTabs: boolean; - private nativeFullScreen: boolean; - private clickThroughInactive: boolean; - private updateMode: string; - private enableCrashReporter: boolean; - private treeHorizontalScrolling: boolean; - private useGridLayout: boolean; - private debugConsoleWordWrap: boolean; + private titleBarStyle: 'native' | 'custom' | undefined; + private nativeTabs: boolean | undefined; + private nativeFullScreen: boolean | undefined; + private clickThroughInactive: boolean | undefined; + private updateMode: string | undefined; + private enableCrashReporter: boolean | undefined; + private treeHorizontalScrolling: boolean | undefined; + private useGridLayout: boolean | undefined; + private debugConsoleWordWrap: boolean | undefined; constructor( @IWindowsService private readonly windowsService: IWindowsService, diff --git a/src/vs/workbench/contrib/search/browser/openFileHandler.ts b/src/vs/workbench/contrib/search/browser/openFileHandler.ts index 39d390233dd8ba50d2796ec77de43284177c7dcc..0374b69749f61d042cf8db38ed2afe24ceb4b6c3 100644 --- a/src/vs/workbench/contrib/search/browser/openFileHandler.ts +++ b/src/vs/workbench/contrib/search/browser/openFileHandler.ts @@ -114,7 +114,7 @@ export interface IOpenFileOptions { export class OpenFileHandler extends QuickOpenHandler { private options: IOpenFileOptions | undefined; private queryBuilder: QueryBuilder; - private cacheState: CacheState; + private cacheState: CacheState | undefined; constructor( @IInstantiationService private readonly instantiationService: IInstantiationService, @@ -143,7 +143,7 @@ export class OpenFileHandler extends QuickOpenHandler { } // Do find results - return this.doFindResults(query, token, this.cacheState.cacheKey, maxSortedResults); + return this.doFindResults(query, token, this.cacheState ? this.cacheState.cacheKey : undefined, maxSortedResults); } private async doFindResults(query: IPreparedQuery, token: CancellationToken, cacheKey?: string, maxSortedResults?: number): Promise { @@ -246,7 +246,7 @@ export class OpenFileHandler extends QuickOpenHandler { } get isCacheLoaded(): boolean { - return this.cacheState && this.cacheState.isLoaded; + return !!this.cacheState && this.cacheState.isLoaded; } getGroupLabel(): string { @@ -279,14 +279,14 @@ export class CacheState { private loadingPhase = LoadingPhase.Created; private promise: Promise | undefined; - constructor(cacheQuery: (cacheKey: string) => IFileQuery, private doLoad: (query: IFileQuery) => Promise, private doDispose: (cacheKey: string) => Promise, private previous: CacheState | null) { + constructor(cacheQuery: (cacheKey: string) => IFileQuery, private doLoad: (query: IFileQuery) => Promise, private doDispose: (cacheKey: string) => Promise, private previous: CacheState | undefined) { this.query = cacheQuery(this._cacheKey); if (this.previous) { const current = objects.assign({}, this.query, { cacheKey: null }); const previous = objects.assign({}, this.previous.query, { cacheKey: null }); if (!objects.equals(current, previous)) { this.previous.dispose(); - this.previous = null; + this.previous = undefined; } } } @@ -315,7 +315,7 @@ export class CacheState { this.loadingPhase = LoadingPhase.Loaded; if (this.previous) { this.previous.dispose(); - this.previous = null; + this.previous = undefined; } }, err => { this.loadingPhase = LoadingPhase.Errored; @@ -337,7 +337,7 @@ export class CacheState { } if (this.previous) { this.previous.dispose(); - this.previous = null; + this.previous = undefined; } } } diff --git a/src/vs/workbench/contrib/stats/electron-browser/workspaceStatsService.ts b/src/vs/workbench/contrib/stats/electron-browser/workspaceStatsService.ts index cf904ae6e7bc776b2bca7f05401207253badb4c2..a597f6e017ef2e990201c48da6f9a5d8df58da75 100644 --- a/src/vs/workbench/contrib/stats/electron-browser/workspaceStatsService.ts +++ b/src/vs/workbench/contrib/stats/electron-browser/workspaceStatsService.ts @@ -91,7 +91,7 @@ const PyModulesToLookFor = [ export class WorkspaceStatsService implements IWorkspaceStatsService { _serviceBrand: undefined; - private _tags: Tags; + private _tags: Tags | undefined; constructor( @IFileService private readonly fileService: IFileService, diff --git a/src/vs/workbench/contrib/welcome/gettingStarted/electron-browser/telemetryOptOut.ts b/src/vs/workbench/contrib/welcome/gettingStarted/electron-browser/telemetryOptOut.ts index f137c1a6fced9b5a02ad4da1d187110c85c48e04..5afb3bb9954f2d35c27802c0b4ef0ec689e2f3c7 100644 --- a/src/vs/workbench/contrib/welcome/gettingStarted/electron-browser/telemetryOptOut.ts +++ b/src/vs/workbench/contrib/welcome/gettingStarted/electron-browser/telemetryOptOut.ts @@ -22,8 +22,7 @@ import { CancellationToken } from 'vs/base/common/cancellation'; export class TelemetryOptOut implements IWorkbenchContribution { private static TELEMETRY_OPT_OUT_SHOWN = 'workbench.telemetryOptOutShown'; - private privacyUrl: string; - private optOutUrl: string; + private privacyUrl: string | undefined; constructor( @IStorageService storageService: IStorageService, @@ -50,7 +49,6 @@ export class TelemetryOptOut implements IWorkbenchContribution { } storageService.store(TelemetryOptOut.TELEMETRY_OPT_OUT_SHOWN, true, StorageScope.GLOBAL); - this.optOutUrl = product.telemetryOptOutUrl; this.privacyUrl = product.privacyStatementUrl || product.telemetryOptOutUrl; if (experimentState && experimentState.state === ExperimentState.Run && telemetryService.isOptedIn) { @@ -58,15 +56,15 @@ export class TelemetryOptOut implements IWorkbenchContribution { return; } - const optOutNotice = localize('telemetryOptOut.optOutNotice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt out]({1}).", this.privacyUrl, this.optOutUrl); - const optInNotice = localize('telemetryOptOut.optInNotice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt in]({1}).", this.privacyUrl, this.optOutUrl); + const optOutNotice = localize('telemetryOptOut.optOutNotice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt out]({1}).", this.privacyUrl, product.telemetryOptOutUrl); + const optInNotice = localize('telemetryOptOut.optInNotice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt in]({1}).", this.privacyUrl, product.telemetryOptOutUrl); notificationService.prompt( Severity.Info, telemetryService.isOptedIn ? optOutNotice : optInNotice, [{ label: localize('telemetryOptOut.readMore', "Read More"), - run: () => openerService.open(URI.parse(this.optOutUrl)) + run: () => openerService.open(URI.parse(product.telemetryOptOutUrl)) }], { sticky: true } ); diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index 7f13270ca830ba30a1e06ec05fccf5e3f0f1fd17..53858c70631417733c53dc2347a72a6ac3f27518 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -70,12 +70,12 @@ const TextInputActions: IAction[] = [ export class ElectronWindow extends Disposable { - private touchBarMenu?: IMenu; - private touchBarUpdater: RunOnceScheduler; + private touchBarMenu: IMenu | undefined; + private touchBarUpdater: RunOnceScheduler | undefined; private readonly touchBarDisposables = this._register(new DisposableStore()); - private lastInstalledTouchedBar: ICommandAction[][]; + private lastInstalledTouchedBar: ICommandAction[][] | undefined; - private previousConfiguredZoomLevel: number; + private previousConfiguredZoomLevel: number | undefined; private addFoldersScheduler: RunOnceScheduler; private pendingFoldersToAdd: URI[]; @@ -406,7 +406,7 @@ export class ElectronWindow extends Disposable { if (!this.touchBarMenu) { this.touchBarMenu = this.editorService.invokeWithinEditorContext(accessor => this.menuService.createMenu(MenuId.TouchBarContext, accessor.get(IContextKeyService))); this.touchBarDisposables.add(this.touchBarMenu); - this.touchBarDisposables.add(this.touchBarMenu.onDidChange(() => this.touchBarUpdater.schedule())); + this.touchBarDisposables.add(this.touchBarMenu.onDidChange(() => this.touchBarUpdater!.schedule())); } const actions: Array = []; diff --git a/src/vs/workbench/services/backup/common/backupFileService.ts b/src/vs/workbench/services/backup/common/backupFileService.ts index 4f782cf641f328203edf5fe3b5ebd72ac16e95ff..de81c2b7d587ba73a4091be66d0c1560bd7dd58a 100644 --- a/src/vs/workbench/services/backup/common/backupFileService.ts +++ b/src/vs/workbench/services/backup/common/backupFileService.ts @@ -113,7 +113,7 @@ export class BackupFileService implements IBackupFileService { @IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService, @IFileService protected fileService: IFileService ) { - this.initialize(); + this.impl = this.initialize(); } protected hashPath(resource: URI): string { @@ -122,13 +122,13 @@ export class BackupFileService implements IBackupFileService { return hash(str).toString(16); } - private initialize(): void { + private initialize(): IBackupFileService { const backupWorkspaceResource = this.environmentService.configuration.backupWorkspaceResource; if (backupWorkspaceResource) { - this.impl = new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, this.fileService); - } else { - this.impl = new InMemoryBackupFileService(this.hashPath); + return new BackupFileServiceImpl(backupWorkspaceResource, this.hashPath, this.fileService); } + + return new InMemoryBackupFileService(this.hashPath); } reinitialize(): void { diff --git a/src/vs/workbench/services/credentials/browser/credentialsService.ts b/src/vs/workbench/services/credentials/browser/credentialsService.ts index 82fe116286ed332b22281fca2753c2313b982110..3bc3637a2b6d8be234c91c5a0174b752444095da 100644 --- a/src/vs/workbench/services/credentials/browser/credentialsService.ts +++ b/src/vs/workbench/services/credentials/browser/credentialsService.ts @@ -60,7 +60,7 @@ class LocalStorageCredentialsProvider implements ICredentialsProvider { static readonly CREDENTIALS_OPENED_KEY = 'credentials.provider'; - private _credentials: ICredential[]; + private _credentials: ICredential[] | undefined; private get credentials(): ICredential[] { if (!this._credentials) { try { diff --git a/src/vs/workbench/services/preferences/common/preferencesEditorInput.ts b/src/vs/workbench/services/preferences/common/preferencesEditorInput.ts index ee813e14fe500a50663d13ba843ff26f3f12570b..41edfc30a954655f7c5af71464cb9aae8b8bda2b 100644 --- a/src/vs/workbench/services/preferences/common/preferencesEditorInput.ts +++ b/src/vs/workbench/services/preferences/common/preferencesEditorInput.ts @@ -60,7 +60,7 @@ export class KeybindingsEditorInput extends EditorInput { static readonly ID: string = 'workbench.input.keybindings'; readonly keybindingsModel: KeybindingsEditorModel; - searchOptions: IKeybindingsEditorSearchOptions | null; + searchOptions: IKeybindingsEditorSearchOptions | null = null; constructor(@IInstantiationService instantiationService: IInstantiationService) { super(); diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 69c2ed28f112e90b9c234b984f66ffc61d2948b1..4014dc4da45355f00d2e3348f06b691905a5c8e0 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -106,6 +106,7 @@ export class TestContextService implements IWorkspaceContextService { constructor(workspace: any = TestWorkspace, options: any = null) { this.workspace = workspace; this.options = options || Object.create(null); + this._onDidChangeWorkspaceName = new Emitter(); this._onDidChangeWorkspaceFolders = new Emitter(); this._onDidChangeWorkbenchState = new Emitter(); }