Skip to content

Commit 6ac9111

Browse files
committed
strictPropertyInitialization
microsoft#78168
1 parent 31cd6ae commit 6ac9111

6 files changed

Lines changed: 40 additions & 38 deletions

File tree

src/vs/base/browser/ui/selectBox/selectBoxCustom.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,21 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
8989
private _isVisible: boolean;
9090
private selectBoxOptions: ISelectBoxOptions;
9191
private selectElement: HTMLSelectElement;
92-
private options: ISelectOptionItem[];
92+
private options: ISelectOptionItem[] = [];
9393
private selected: number;
9494
private readonly _onDidSelect: Emitter<ISelectData>;
9595
private styles: ISelectBoxStyles;
96-
private listRenderer: SelectListRenderer;
97-
private contextViewProvider: IContextViewProvider;
98-
private selectDropDownContainer: HTMLElement;
99-
private styleElement: HTMLStyleElement;
100-
private selectList: List<ISelectOptionItem>;
101-
private selectDropDownListContainer: HTMLElement;
102-
private widthControlElement: HTMLElement;
103-
private _currentSelection: number;
104-
private _dropDownPosition: AnchorPosition;
96+
private listRenderer!: SelectListRenderer;
97+
private contextViewProvider!: IContextViewProvider;
98+
private selectDropDownContainer!: HTMLElement;
99+
private styleElement!: HTMLStyleElement;
100+
private selectList!: List<ISelectOptionItem>;
101+
private selectDropDownListContainer!: HTMLElement;
102+
private widthControlElement!: HTMLElement;
103+
private _currentSelection = 0;
104+
private _dropDownPosition!: AnchorPosition;
105105
private _hasDetails: boolean = false;
106-
private selectionDetailsPane: HTMLElement;
106+
private selectionDetailsPane!: HTMLElement;
107107
private _skipLayout: boolean = false;
108108

109109
private _sticky: boolean = false; // for dev purposes only
@@ -241,7 +241,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
241241
}
242242

243243
public setOptions(options: ISelectOptionItem[], selected?: number): void {
244-
if (!this.options || !arrays.equals(this.options, options)) {
244+
if (!arrays.equals(this.options, options)) {
245245
this.options = options;
246246
this.selectElement.options.length = 0;
247247
this._hasDetails = false;
@@ -266,7 +266,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
266266

267267
// Mirror options in drop-down
268268
// Populate select list for non-native select mode
269-
if (this.selectList && !!this.options) {
269+
if (this.selectList) {
270270
this.selectList.splice(0, this.selectList.length, this.options);
271271
}
272272
}
@@ -689,7 +689,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
689689
private setWidthControlElement(container: HTMLElement): number {
690690
let elementWidth = 0;
691691

692-
if (container && !!this.options) {
692+
if (container) {
693693
let longest = 0;
694694
let longestLength = 0;
695695

src/vs/workbench/browser/parts/compositeBar.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ export interface ICompositeBarOptions {
4646

4747
export class CompositeBar extends Widget implements ICompositeBar {
4848

49-
private dimension: Dimension;
49+
private dimension: Dimension | undefined;
5050

51-
private compositeSwitcherBar: ActionBar;
52-
private compositeOverflowAction: CompositeOverflowActivityAction | null;
51+
private compositeSwitcherBar!: ActionBar;
52+
private compositeOverflowAction: CompositeOverflowActivityAction | undefined;
5353
private compositeOverflowActionViewItem: CompositeOverflowActivityActionViewItem | undefined;
5454

5555
private model: CompositeBarModel;
@@ -343,7 +343,7 @@ export class CompositeBar extends Widget implements ICompositeBar {
343343
this.compositeSwitcherBar.pull(this.compositeSwitcherBar.length() - 1);
344344

345345
this.compositeOverflowAction.dispose();
346-
this.compositeOverflowAction = null;
346+
this.compositeOverflowAction = undefined;
347347

348348
if (this.compositeOverflowActionViewItem) {
349349
this.compositeOverflowActionViewItem.dispose();
@@ -460,7 +460,7 @@ interface ICompositeBarModelItem extends ICompositeBarItem {
460460

461461
class CompositeBarModel {
462462

463-
private _items: ICompositeBarModelItem[];
463+
private _items: ICompositeBarModelItem[] = [];
464464
private readonly options: ICompositeBarOptions;
465465
activeItem?: ICompositeBarModelItem;
466466

src/vs/workbench/browser/parts/compositeBarActions.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ export interface IActivityActionViewItemOptions extends IBaseActionViewItemOptio
124124
}
125125

126126
export class ActivityActionViewItem extends BaseActionViewItem {
127-
protected container: HTMLElement;
128-
protected label: HTMLElement;
129-
protected badge: HTMLElement;
130-
protected options: IActivityActionViewItemOptions;
127+
protected container!: HTMLElement;
128+
protected label!: HTMLElement;
129+
protected badge!: HTMLElement;
130+
protected options!: IActivityActionViewItemOptions;
131131

132-
private badgeContent: HTMLElement;
132+
private badgeContent: HTMLElement | undefined;
133133
private readonly badgeDisposable = this._register(new MutableDisposable());
134134
private mouseUpTimeout: any;
135135

@@ -347,7 +347,7 @@ export class CompositeOverflowActivityAction extends ActivityAction {
347347
}
348348

349349
export class CompositeOverflowActivityActionViewItem extends ActivityActionViewItem {
350-
private actions: Action[];
350+
private actions: Action[] | undefined;
351351

352352
constructor(
353353
action: ActivityAction,
@@ -371,8 +371,8 @@ export class CompositeOverflowActivityActionViewItem extends ActivityActionViewI
371371

372372
this.contextMenuService.showContextMenu({
373373
getAnchor: () => this.element!,
374-
getActions: () => this.actions,
375-
onHide: () => dispose(this.actions)
374+
getActions: () => this.actions!,
375+
onHide: () => dispose(this.actions!)
376376
});
377377
}
378378

@@ -402,7 +402,9 @@ export class CompositeOverflowActivityActionViewItem extends ActivityActionViewI
402402
dispose(): void {
403403
super.dispose();
404404

405-
this.actions = dispose(this.actions);
405+
if (this.actions) {
406+
this.actions = dispose(this.actions);
407+
}
406408
}
407409
}
408410

@@ -431,7 +433,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
431433

432434
private static manageExtensionAction: ManageExtensionAction;
433435

434-
private compositeActivity: IActivity | null;
436+
private compositeActivity: IActivity | undefined;
435437
private compositeTransfer: LocalSelectionTransfer<DraggedCompositeIdentifier>;
436438

437439
constructor(
@@ -454,7 +456,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
454456
CompositeActionViewItem.manageExtensionAction = instantiationService.createInstance(ManageExtensionAction);
455457
}
456458

457-
this._register(compositeActivityAction.onDidChangeActivity(() => { this.compositeActivity = null; this.updateActivity(); }, this));
459+
this._register(compositeActivityAction.onDidChangeActivity(() => { this.compositeActivity = undefined; this.updateActivity(); }, this));
458460
}
459461

460462
protected get activity(): IActivity {

src/vs/workbench/browser/parts/panel/panelPart.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
8383
private compositeBar: CompositeBar;
8484
private compositeActions: Map<string, { activityAction: PanelActivityAction, pinnedAction: ToggleCompositePinnedAction }> = new Map();
8585

86-
private blockOpeningPanel: boolean;
87-
private _contentDimension: Dimension;
86+
private blockOpeningPanel = false;
87+
private _contentDimension: Dimension | undefined;
8888

8989
constructor(
9090
@INotificationService notificationService: INotificationService,
@@ -367,7 +367,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
367367
private onDidStorageChange(e: IWorkspaceStorageChangeEvent): void {
368368
if (e.key === PanelPart.PINNED_PANELS && e.scope === StorageScope.GLOBAL
369369
&& this.cachedPanelsValue !== this.getStoredCachedPanelsValue() /* This checks if current window changed the value or not */) {
370-
this._cachedPanelsValue = null;
370+
this._cachedPanelsValue = undefined;
371371
const newCompositeItems: ICompositeBarItem[] = [];
372372
const compositeItems = this.compositeBar.getCompositeBarItems();
373373
const cachedPanels = this.getCachedPanels();
@@ -422,7 +422,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
422422
return cachedPanels;
423423
}
424424

425-
private _cachedPanelsValue: string | null;
425+
private _cachedPanelsValue: string | undefined;
426426
private get cachedPanelsValue(): string {
427427
if (!this._cachedPanelsValue) {
428428
this._cachedPanelsValue = this.getStoredCachedPanelsValue();

src/vs/workbench/browser/viewlet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const Extensions = {
7676
};
7777

7878
export class ViewletRegistry extends CompositeRegistry<Viewlet> {
79-
private defaultViewletId: string;
79+
private defaultViewletId!: string;
8080

8181
/**
8282
* Registers a viewlet to the platform.

src/vs/workbench/services/output/common/outputChannelModel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export abstract class AbstractFileOutputChannelModel extends Disposable implemen
5858
readonly onDispose: Event<void> = this._onDispose.event;
5959

6060
protected modelUpdater: RunOnceScheduler;
61-
protected model: ITextModel | null;
61+
protected model: ITextModel | null = null;
6262

6363
protected startOffset: number = 0;
6464
protected endOffset: number = 0;
@@ -288,7 +288,7 @@ export class BufferredOutputChannel extends Disposable implements IOutputChannel
288288
readonly onDispose: Event<void> = this._onDispose.event;
289289

290290
private modelUpdater: RunOnceScheduler;
291-
private model: ITextModel | null;
291+
private model: ITextModel | null = null;
292292
private readonly bufferredContent: BufferedContent;
293293
private lastReadId: number | undefined = undefined;
294294

@@ -414,4 +414,4 @@ class BufferedContent {
414414
return { value, id };
415415
}
416416
}
417-
}
417+
}

0 commit comments

Comments
 (0)