Skip to content

Commit 06701f5

Browse files
committed
add a bunch of strict field initializations
1 parent 28520b8 commit 06701f5

27 files changed

Lines changed: 67 additions & 69 deletions

File tree

src/vs/base/browser/ui/breadcrumbs/breadcrumbsWidget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export class BreadcrumbsWidget {
7777
private _focusedItemIdx: number = -1;
7878
private _selectedItemIdx: number = -1;
7979

80-
private _pendingLayout: IDisposable;
81-
private _dimension: dom.Dimension;
80+
private _pendingLayout: IDisposable | undefined;
81+
private _dimension: dom.Dimension | undefined;
8282

8383
constructor(
8484
container: HTMLElement

src/vs/base/common/event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ export interface IWaitUntil {
645645

646646
export class AsyncEmitter<T extends IWaitUntil> extends Emitter<T> {
647647

648-
private _asyncDeliveryQueue: [Listener<T>, T, Promise<any>[]][];
648+
private _asyncDeliveryQueue?: [Listener<T>, T, Promise<any>[]][];
649649

650650
async fireAsync(eventFn: (thenables: Promise<any>[], listener: Function) => T): Promise<void> {
651651
if (!this._listeners) {

src/vs/editor/contrib/codelens/codelensWidget.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget {
6060
private readonly _editor: editorBrowser.ICodeEditor;
6161
private readonly _commands = new Map<string, Command>();
6262

63-
private _widgetPosition: editorBrowser.IContentWidgetPosition;
63+
private _widgetPosition?: editorBrowser.IContentWidgetPosition;
6464

6565
constructor(
6666
editor: editorBrowser.ICodeEditor,
@@ -147,8 +147,8 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget {
147147
};
148148
}
149149

150-
getPosition(): editorBrowser.IContentWidgetPosition {
151-
return this._widgetPosition;
150+
getPosition(): editorBrowser.IContentWidgetPosition | null {
151+
return this._widgetPosition || null;
152152
}
153153

154154
isVisible(): boolean {

src/vs/editor/contrib/documentSymbols/outlineTree.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,19 @@ export class OutlineIdentityProvider implements IIdentityProvider<OutlineItem> {
4545

4646
export class OutlineGroupTemplate {
4747
static id = 'OutlineGroupTemplate';
48-
49-
labelContainer: HTMLElement;
50-
label: HighlightedLabel;
48+
constructor(
49+
readonly labelContainer: HTMLElement,
50+
readonly label: HighlightedLabel,
51+
) { }
5152
}
5253

5354
export class OutlineElementTemplate {
5455
static id = 'OutlineElementTemplate';
55-
container: HTMLElement;
56-
iconLabel: IconLabel;
57-
decoration: HTMLElement;
56+
constructor(
57+
readonly container: HTMLElement,
58+
readonly iconLabel: IconLabel,
59+
readonly decoration: HTMLElement,
60+
) { }
5861
}
5962

6063
export class OutlineVirtualDelegate implements IListVirtualDelegate<OutlineItem> {
@@ -80,7 +83,7 @@ export class OutlineGroupRenderer implements ITreeRenderer<OutlineGroup, FuzzySc
8083
const labelContainer = dom.$('.outline-element-label');
8184
dom.addClass(container, 'outline-element');
8285
dom.append(container, labelContainer);
83-
return { labelContainer, label: new HighlightedLabel(labelContainer, true) };
86+
return new OutlineGroupTemplate(labelContainer, new HighlightedLabel(labelContainer, true));
8487
}
8588

8689
renderElement(node: ITreeNode<OutlineGroup, FuzzyScore>, index: number, template: OutlineGroupTemplate): void {
@@ -109,7 +112,7 @@ export class OutlineElementRenderer implements ITreeRenderer<OutlineElement, Fuz
109112
const iconLabel = new IconLabel(container, { supportHighlights: true });
110113
const decoration = dom.$('.outline-element-decoration');
111114
container.appendChild(decoration);
112-
return { container, iconLabel, decoration };
115+
return new OutlineElementTemplate(container, iconLabel, decoration);
113116
}
114117

115118
renderElement(node: ITreeNode<OutlineElement, FuzzyScore>, index: number, template: OutlineElementTemplate): void {

src/vs/editor/contrib/goToDefinition/goToDefinitionMouse.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,16 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
3434

3535
private readonly editor: ICodeEditor;
3636
private readonly toUnhook = new DisposableStore();
37-
private decorations: string[];
38-
private currentWordUnderMouse: IWordAtPosition | null;
39-
private previousPromise: CancelablePromise<LocationLink[] | null> | null;
37+
private decorations: string[] = [];
38+
private currentWordUnderMouse: IWordAtPosition | null = null;
39+
private previousPromise: CancelablePromise<LocationLink[] | null> | null = null;
4040

4141
constructor(
4242
editor: ICodeEditor,
4343
@ITextModelService private readonly textModelResolverService: ITextModelService,
4444
@IModeService private readonly modeService: IModeService
4545
) {
46-
this.decorations = [];
4746
this.editor = editor;
48-
this.previousPromise = null;
4947

5048
let linkGesture = new ClickLinkGesture(editor);
5149
this.toUnhook.add(linkGesture);

src/vs/editor/contrib/referenceSearch/referencesModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class FileReferences implements IDisposable {
8989

9090
private _children: OneReference[];
9191
private _preview?: FilePreview;
92-
private _resolved: boolean;
92+
private _resolved?: boolean;
9393
private _loadFailure: any;
9494

9595
constructor(private readonly _parent: ReferencesModel, private readonly _uri: URI) {

src/vs/editor/contrib/snippet/snippetParser.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,8 @@ export class Scanner {
5656
|| (ch >= CharCode.A && ch <= CharCode.Z);
5757
}
5858

59-
value: string;
60-
pos: number;
61-
62-
constructor() {
63-
this.text('');
64-
}
59+
value: string = '';
60+
pos: number = 0;
6561

6662
text(value: string) {
6763
this.value = value;

src/vs/editor/contrib/suggest/suggestAlternatives.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class SuggestAlternatives {
1515

1616
private readonly _ckOtherSuggestions: IContextKey<boolean>;
1717

18-
private _index: number;
18+
private _index: number = 0;
1919
private _model: CompletionModel | undefined;
2020
private _acceptNext: ((selected: ISelectedSuggestion) => any) | undefined;
2121
private _listener: IDisposable | undefined;

src/vs/editor/contrib/suggest/wordContextKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class WordContextKey extends Disposable {
1313

1414
private readonly _ckAtEnd: IContextKey<boolean>;
1515

16-
private _enabled: boolean;
16+
private _enabled: boolean = false;
1717
private _selectionListener?: IDisposable;
1818

1919
constructor(

src/vs/workbench/api/browser/mainThreadCodeInsets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class EditorWebviewZone implements IViewZone {
2121
readonly afterColumn: number;
2222
readonly heightInLines: number;
2323

24-
private _id: number;
24+
private _id?: number;
2525
// suppressMouseDown?: boolean | undefined;
2626
// heightInPx?: number | undefined;
2727
// minWidthInPx?: number | undefined;
@@ -46,7 +46,7 @@ class EditorWebviewZone implements IViewZone {
4646
}
4747

4848
dispose(): void {
49-
this.editor.changeViewZones(accessor => accessor.removeZone(this._id));
49+
this.editor.changeViewZones(accessor => this._id && accessor.removeZone(this._id));
5050
}
5151
}
5252

0 commit comments

Comments
 (0)