Skip to content

Commit

Permalink
strictPropertyInitialization
Browse files Browse the repository at this point in the history
related to #78168
  • Loading branch information
joaomoreno committed Aug 5, 2019
1 parent b082da1 commit 3015179
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/vs/base/browser/ui/actionbar/actionbar.ts
Expand Up @@ -37,7 +37,7 @@ export class BaseActionViewItem extends Disposable implements IActionViewItem {
_context: any;
_action: IAction;

private _actionRunner: IActionRunner;
private _actionRunner!: IActionRunner;

constructor(context: any, action: IAction, protected options?: IBaseActionViewItemOptions) {
super();
Expand Down Expand Up @@ -232,7 +232,7 @@ export interface IActionViewItemOptions extends IBaseActionViewItemOptions {

export class ActionViewItem extends BaseActionViewItem {

protected label: HTMLElement;
protected label!: HTMLElement;
protected options: IActionViewItemOptions;

private cssClass?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/centered/centeredViewLayout.ts
Expand Up @@ -55,7 +55,7 @@ export class CenteredViewLayout implements IDisposable {
private splitView?: SplitView;
private width: number = 0;
private height: number = 0;
private style: ICenteredViewStyles | undefined;
private style!: ICenteredViewStyles;
private didLayout = false;
private emptyViews: ISplitViewView[] | undefined;
private readonly splitViewDisposables = new DisposableStore();
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/checkbox/checkbox.ts
Expand Up @@ -32,7 +32,7 @@ const defaultOpts = {

export class CheckboxActionViewItem extends BaseActionViewItem {

private checkbox: Checkbox | undefined;
private checkbox!: Checkbox;
private readonly disposables = new DisposableStore();

render(container: HTMLElement): void {
Expand Down
21 changes: 9 additions & 12 deletions src/vs/base/browser/ui/contextview/contextview.ts
Expand Up @@ -5,7 +5,7 @@

import 'vs/css!./contextview';
import * as DOM from 'vs/base/browser/dom';
import { IDisposable, dispose, toDisposable, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { IDisposable, toDisposable, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { Range } from 'vs/base/common/range';

export interface IAnchor {
Expand Down Expand Up @@ -100,11 +100,11 @@ export class ContextView extends Disposable {
private static readonly BUBBLE_UP_EVENTS = ['click', 'keydown', 'focus', 'blur'];
private static readonly BUBBLE_DOWN_EVENTS = ['click'];

private container: HTMLElement | null;
private container: HTMLElement | null = null;
private view: HTMLElement;
private delegate: IDelegate | null;
private toDisposeOnClean: IDisposable | null;
private toDisposeOnSetContainer: IDisposable;
private delegate: IDelegate | null = null;
private toDisposeOnClean: IDisposable = Disposable.None;
private toDisposeOnSetContainer: IDisposable = Disposable.None;

constructor(container: HTMLElement) {
super();
Expand All @@ -120,7 +120,7 @@ export class ContextView extends Disposable {

setContainer(container: HTMLElement | null): void {
if (this.container) {
dispose(this.toDisposeOnSetContainer);
this.toDisposeOnSetContainer.dispose();
this.container.removeChild(this.view);
this.container = null;
}
Expand Down Expand Up @@ -159,7 +159,7 @@ export class ContextView extends Disposable {
DOM.show(this.view);

// Render content
this.toDisposeOnClean = delegate.render(this.view);
this.toDisposeOnClean = delegate.render(this.view) || Disposable.None;

// Set active delegate
this.delegate = delegate;
Expand Down Expand Up @@ -267,10 +267,7 @@ export class ContextView extends Disposable {
delegate.onHide(data);
}

if (this.toDisposeOnClean) {
this.toDisposeOnClean.dispose();
this.toDisposeOnClean = null;
}
this.toDisposeOnClean.dispose();

DOM.hide(this.view);
}
Expand All @@ -294,4 +291,4 @@ export class ContextView extends Disposable {

super.dispose();
}
}
}
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/countBadge/countBadge.ts
Expand Up @@ -29,7 +29,7 @@ const defaultOpts = {
export class CountBadge {

private element: HTMLElement;
private count: number;
private count: number = 0;
private countFormat: string;
private titleFormat: string;

Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/grid/gridview.ts
Expand Up @@ -610,7 +610,7 @@ export class GridView implements IDisposable {
private styles: IGridViewStyles;
private proportionalLayout: boolean;

private _root: BranchNode;
private _root!: BranchNode;
private onDidSashResetRelay = new Relay<number[]>();
readonly onDidSashReset: Event<number[]> = this.onDidSashResetRelay.event;

Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/list/listPaging.ts
Expand Up @@ -73,7 +73,7 @@ class PagedRenderer<TElement, TTemplateData> implements IListRenderer<number, IT
export class PagedList<T> implements IDisposable {

private list: List<number>;
private _model: IPagedModel<T>;
private _model!: IPagedModel<T>;

constructor(
container: HTMLElement,
Expand Down
7 changes: 3 additions & 4 deletions src/vs/base/browser/ui/list/listView.ts
Expand Up @@ -163,16 +163,15 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
private lastRenderTop: number;
private lastRenderHeight: number;
private renderWidth = 0;
private gesture: Gesture;
private rowsContainer: HTMLElement;
private scrollableElement: ScrollableElement;
private _scrollHeight: number;
private _scrollHeight: number = 0;
private scrollableElementUpdateDisposable: IDisposable | null = null;
private scrollableElementWidthDelayer = new Delayer<void>(50);
private splicing = false;
private dragOverAnimationDisposable: IDisposable | undefined;
private dragOverAnimationStopDisposable: IDisposable = Disposable.None;
private dragOverMouseY: number;
private dragOverMouseY: number = 0;
private setRowLineHeight: boolean;
private supportDynamicHeights: boolean;
private horizontalScrolling: boolean;
Expand Down Expand Up @@ -245,7 +244,7 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
this.domNode.appendChild(this.scrollableElement.getDomNode());
container.appendChild(this.domNode);

this.disposables = [this.rangeMap, this.gesture, this.scrollableElement, this.cache];
this.disposables = [this.rangeMap, this.scrollableElement, this.cache];

this.scrollableElement.onScroll(this.onScroll, this, this.disposables);
domEvent(this.rowsContainer, TouchEventType.Change)(this.onTouchChange, this, this.disposables);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/list/listWidget.ts
Expand Up @@ -519,7 +519,7 @@ const DefaultOpenController: IOpenController = {
export class MouseController<T> implements IDisposable {

private multipleSelectionSupport: boolean;
readonly multipleSelectionController: IMultipleSelectionController<T>;
readonly multipleSelectionController: IMultipleSelectionController<T> | undefined;
private openController: IOpenController;
private mouseSupport: boolean;
private readonly disposables = new DisposableStore();
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/sash/sash.ts
Expand Up @@ -61,7 +61,7 @@ export class Sash extends Disposable {
private el: HTMLElement;
private layoutProvider: ISashLayoutProvider;
private hidden: boolean;
private orientation: Orientation;
private orientation!: Orientation;

private _state: SashState = SashState.Enabled;
get state(): SashState { return this._state; }
Expand Down
8 changes: 4 additions & 4 deletions src/vs/base/browser/ui/splitview/panelview.ts
Expand Up @@ -42,8 +42,8 @@ export abstract class Panel extends Disposable implements IView {
private static readonly HEADER_SIZE = 22;

readonly element: HTMLElement;
private header: HTMLElement;
private body: HTMLElement;
private header!: HTMLElement;
private body!: HTMLElement;

protected _expanded: boolean;

Expand Down Expand Up @@ -109,7 +109,7 @@ export abstract class Panel extends Disposable implements IView {
return headerSize + maximumBodySize;
}

width: number;
width: number = 0;

constructor(options: IPanelOptions = {}) {
super();
Expand Down Expand Up @@ -371,7 +371,7 @@ export class PanelView extends Disposable {
private dndContext: IDndContext = { draggable: null };
private el: HTMLElement;
private panelItems: IPanelItem[] = [];
private width: number;
private width: number = 0;
private splitview: SplitView;
private animationTimer: number | undefined = undefined;

Expand Down
12 changes: 6 additions & 6 deletions src/vs/base/browser/ui/splitview/splitview.ts
Expand Up @@ -203,7 +203,7 @@ export class SplitView extends Disposable {
private proportions: undefined | number[] = undefined;
private viewItems: ViewItem[] = [];
private sashItems: ISashItem[] = [];
private sashDragState: ISashDragState;
private sashDragState: ISashDragState | undefined;
private state: State = State.Idle;
private inverseAltBehavior: boolean;
private proportionalLayout: boolean;
Expand Down Expand Up @@ -499,8 +499,8 @@ export class SplitView extends Disposable {

// This way, we can press Alt while we resize a sash, macOS style!
const disposable = combinedDisposable(
domEvent(document.body, 'keydown')(e => resetSashDragState(this.sashDragState.current, e.altKey)),
domEvent(document.body, 'keyup')(() => resetSashDragState(this.sashDragState.current, false))
domEvent(document.body, 'keydown')(e => resetSashDragState(this.sashDragState!.current, e.altKey)),
domEvent(document.body, 'keyup')(() => resetSashDragState(this.sashDragState!.current, false))
);

const resetSashDragState = (start: number, alt: boolean) => {
Expand Down Expand Up @@ -572,8 +572,8 @@ export class SplitView extends Disposable {
}

private onSashChange({ current }: ISashEvent): void {
const { index, start, sizes, alt, minDelta, maxDelta, snapBefore, snapAfter } = this.sashDragState;
this.sashDragState.current = current;
const { index, start, sizes, alt, minDelta, maxDelta, snapBefore, snapAfter } = this.sashDragState!;
this.sashDragState!.current = current;

const delta = current - start;
const newDelta = this.resize(index, delta, sizes, undefined, undefined, minDelta, maxDelta, snapBefore, snapAfter);
Expand All @@ -596,7 +596,7 @@ export class SplitView extends Disposable {

private onSashEnd(index: number): void {
this._onDidSashChange.fire(index);
this.sashDragState.disposable.dispose();
this.sashDragState!.disposable.dispose();
this.saveProportions();
}

Expand Down
5 changes: 3 additions & 2 deletions src/vs/base/browser/ui/toolbar/toolbar.ts
Expand Up @@ -33,7 +33,7 @@ export class ToolBar extends Disposable {
private actionBar: ActionBar;
private toggleMenuAction: ToggleMenuAction;
private toggleMenuActionViewItem = this._register(new MutableDisposable<DropdownMenuActionViewItem>());
private hasSecondaryActions: boolean;
private hasSecondaryActions: boolean = false;
private lookupKeybindings: boolean;

constructor(container: HTMLElement, contextMenuProvider: IContextMenuProvider, options: IToolBarOptions = { orientation: ActionsOrientation.HORIZONTAL }) {
Expand Down Expand Up @@ -162,6 +162,7 @@ class ToggleMenuAction extends Action {
title = title || nls.localize('moreActions', "More Actions...");
super(ToggleMenuAction.ID, title, undefined, true);

this._menuActions = [];
this.toggleDropdownMenu = toggleDropdownMenu;
}

Expand All @@ -178,4 +179,4 @@ class ToggleMenuAction extends Action {
set menuActions(actions: ReadonlyArray<IAction>) {
this._menuActions = actions;
}
}
}
6 changes: 3 additions & 3 deletions src/vs/base/browser/ui/tree/abstractTree.ts
Expand Up @@ -451,8 +451,8 @@ class TypeFilter<T> implements ITreeFilter<T, FuzzyScore>, IDisposable {
private _matchCount = 0;
get matchCount(): number { return this._matchCount; }

private _pattern: string;
private _lowercasePattern: string;
private _pattern: string = '';
private _lowercasePattern: string = '';
private disposables: IDisposable[] = [];

set pattern(pattern: string) {
Expand Down Expand Up @@ -543,7 +543,7 @@ class TypeFilterController<T, TFilterData> implements IDisposable {
private _filterOnType: boolean;
get filterOnType(): boolean { return this._filterOnType; }

private _empty: boolean;
private _empty: boolean = false;
get empty(): boolean { return this._empty; }

private _onDidChangeEmptyState = new Emitter<boolean>();
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/tree/compressedObjectTree.ts
Expand Up @@ -17,7 +17,7 @@ export interface IObjectTreeOptions<T, TFilterData = void> extends IAbstractTree

export class CompressedObjectTree<T extends NonNullable<any>, TFilterData = void> extends AbstractTree<ICompressedTreeNode<T> | null, TFilterData, T | null> {

protected model: CompressedTreeModel<T, TFilterData>;
protected model!: CompressedTreeModel<T, TFilterData>;

get onDidChangeCollapseState(): Event<ICollapseStateChangeEvent<ICompressedTreeNode<T> | null, TFilterData>> { return this.model.onDidChangeCollapseState; }

Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/tree/dataTree.ts
Expand Up @@ -23,7 +23,7 @@ export interface IDataTreeViewState {

export class DataTree<TInput, T, TFilterData = void> extends AbstractTree<T | null, TFilterData, T | null> {

protected model: ObjectTreeModel<T, TFilterData>;
protected model!: ObjectTreeModel<T, TFilterData>;
private input: TInput | undefined;

private identityProvider: IIdentityProvider<T> | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/tree/indexTree.ts
Expand Up @@ -15,7 +15,7 @@ export interface IIndexTreeOptions<T, TFilterData = void> extends IAbstractTreeO

export class IndexTree<T, TFilterData = void> extends AbstractTree<T, TFilterData, number[]> {

protected model: IndexTreeModel<T, TFilterData>;
protected model!: IndexTreeModel<T, TFilterData>;

constructor(
container: HTMLElement,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/tree/objectTree.ts
Expand Up @@ -17,7 +17,7 @@ export interface IObjectTreeOptions<T, TFilterData = void> extends IAbstractTree

export class ObjectTree<T extends NonNullable<any>, TFilterData = void> extends AbstractTree<T | null, TFilterData, T | null> {

protected model: IObjectTreeModel<T, TFilterData>;
protected model!: IObjectTreeModel<T, TFilterData>;

get onDidChangeCollapseState(): Event<ICollapseStateChangeEvent<T | null, TFilterData>> { return this.model.onDidChangeCollapseState; }

Expand Down
6 changes: 3 additions & 3 deletions src/vs/base/parts/tree/browser/treeModel.ts
Expand Up @@ -862,10 +862,10 @@ export interface IRefreshEvent extends IBaseEvent {
export class TreeModel {

private context: _.ITreeContext;
private lock: Lock;
private lock!: Lock;
private input: Item | null;
private registry: ItemRegistry;
private registryDisposable: IDisposable;
private registry!: ItemRegistry;
private registryDisposable!: IDisposable;
private traitsToItems: ITraitMap;

private _onSetInput = new Emitter<IInputEvent>();
Expand Down

0 comments on commit 3015179

Please sign in to comment.