Skip to content

Commit e354c8d

Browse files
committed
remove all StrictNullOverride
related to microsoft#78168
1 parent dedf0de commit e354c8d

8 files changed

Lines changed: 33 additions & 82 deletions

File tree

src/vs/base/browser/ui/inputbox/inputBox.ts

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,7 @@ export class InputBox extends Widget {
220220
});
221221
}
222222

223-
setTimeout(() => {
224-
if (!this.input) {
225-
return;
226-
}
227-
228-
this.updateMirror();
229-
}, 0);
223+
setTimeout(() => this.updateMirror(), 0);
230224

231225
// Support actions
232226
if (this.options.actions) {
@@ -246,21 +240,17 @@ export class InputBox extends Widget {
246240
}
247241

248242
public setPlaceHolder(placeHolder: string): void {
249-
if (this.input) {
250-
this.input.setAttribute('placeholder', placeHolder);
251-
this.input.title = placeHolder;
252-
}
243+
this.input.setAttribute('placeholder', placeHolder);
244+
this.input.title = placeHolder;
253245
}
254246

255247
public setAriaLabel(label: string): void {
256248
this.ariaLabel = label;
257249

258-
if (this.input) {
259-
if (label) {
260-
this.input.setAttribute('aria-label', this.ariaLabel);
261-
} else {
262-
this.input.removeAttribute('aria-label');
263-
}
250+
if (label) {
251+
this.input.setAttribute('aria-label', this.ariaLabel);
252+
} else {
253+
this.input.removeAttribute('aria-label');
264254
}
265255
}
266256

@@ -560,20 +550,18 @@ export class InputBox extends Widget {
560550
}
561551

562552
protected applyStyles(): void {
563-
if (this.element) {
564-
const background = this.inputBackground ? this.inputBackground.toString() : null;
565-
const foreground = this.inputForeground ? this.inputForeground.toString() : null;
566-
const border = this.inputBorder ? this.inputBorder.toString() : null;
553+
const background = this.inputBackground ? this.inputBackground.toString() : null;
554+
const foreground = this.inputForeground ? this.inputForeground.toString() : null;
555+
const border = this.inputBorder ? this.inputBorder.toString() : null;
567556

568-
this.element.style.backgroundColor = background;
569-
this.element.style.color = foreground;
570-
this.input.style.backgroundColor = background;
571-
this.input.style.color = foreground;
557+
this.element.style.backgroundColor = background;
558+
this.element.style.color = foreground;
559+
this.input.style.backgroundColor = background;
560+
this.input.style.color = foreground;
572561

573-
this.element.style.borderWidth = border ? '1px' : null;
574-
this.element.style.borderStyle = border ? 'solid' : null;
575-
this.element.style.borderColor = border;
576-
}
562+
this.element.style.borderWidth = border ? '1px' : null;
563+
this.element.style.borderStyle = border ? 'solid' : null;
564+
this.element.style.borderColor = border;
577565
}
578566

579567
public layout(): void {
@@ -594,13 +582,11 @@ export class InputBox extends Widget {
594582
public dispose(): void {
595583
this._hideMessage();
596584

597-
this.element = null!; // StrictNullOverride: nulling out ok in dispose
598-
this.input = null!; // StrictNullOverride: nulling out ok in dispose
599-
this.contextViewProvider = undefined;
600585
this.message = null;
601-
this.validation = undefined;
602-
this.state = null!; // StrictNullOverride: nulling out ok in dispose
603-
this.actionbar = undefined;
586+
587+
if (this.actionbar) {
588+
this.actionbar.dispose();
589+
}
604590

605591
super.dispose();
606592
}

src/vs/base/browser/ui/list/listView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
248248
this.domNode.appendChild(this.scrollableElement.getDomNode());
249249
container.appendChild(this.domNode);
250250

251-
this.disposables = [this.rangeMap, this.scrollableElement, this.cache];
251+
this.disposables = [this.scrollableElement, this.cache];
252252

253253
this.scrollableElement.onScroll(this.onScroll, this, this.disposables);
254254
domEvent(this.rowsContainer, TouchEventType.Change)(this.onTouchChange, this, this.disposables);

src/vs/base/browser/ui/list/rangeMap.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,4 @@ export class RangeMap {
186186

187187
return -1;
188188
}
189-
190-
dispose() {
191-
this.groups = null!; // StrictNullOverride: nulling out ok in dispose
192-
}
193189
}

src/vs/base/browser/ui/list/rowCache.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ export class RowCache<T> implements IDisposable {
7979
return result;
8080
}
8181

82-
private garbageCollect(): void {
83-
if (!this.renderers) {
84-
return;
85-
}
86-
82+
dispose(): void {
8783
this.cache.forEach((cachedRows, templateId) => {
8884
for (const cachedRow of cachedRows) {
8985
const renderer = this.getRenderer(templateId);
@@ -96,17 +92,11 @@ export class RowCache<T> implements IDisposable {
9692
this.cache.clear();
9793
}
9894

99-
dispose(): void {
100-
this.garbageCollect();
101-
this.cache.clear();
102-
this.renderers = null!; // StrictNullOverride: nulling out ok in dispose
103-
}
104-
10595
private getRenderer(templateId: string): IListRenderer<T, any> {
10696
const renderer = this.renderers.get(templateId);
10797
if (!renderer) {
10898
throw new Error(`No renderer found for ${templateId}`);
10999
}
110100
return renderer;
111101
}
112-
}
102+
}

src/vs/base/browser/ui/sash/sash.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,6 @@ export class Sash extends Disposable {
402402

403403
dispose(): void {
404404
super.dispose();
405-
406-
if (this.el && this.el.parentElement) {
407-
this.el.parentElement.removeChild(this.el);
408-
}
409-
410-
this.el = null!; // StrictNullOverride: nulling out ok in dispose
405+
this.el.remove();
411406
}
412407
}

src/vs/base/parts/tree/browser/treeImpl.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ export class Tree implements _.ITree {
110110
}
111111

112112
get onDidFocus(): Event<void> {
113-
return this.view && this.view.onDOMFocus;
113+
return this.view.onDOMFocus;
114114
}
115115

116116
get onDidBlur(): Event<void> {
117-
return this.view && this.view.onDOMBlur;
117+
return this.view.onDOMBlur;
118118
}
119119

120120
get onDidScroll(): Event<void> {
121-
return this.view && this.view.onDidScroll;
121+
return this.view.onDidScroll;
122122
}
123123

124124
public getHTMLElement(): HTMLElement {
@@ -263,16 +263,8 @@ export class Tree implements _.ITree {
263263

264264
public dispose(): void {
265265
this._onDispose.fire();
266-
267-
if (this.model !== null) {
268-
this.model.dispose();
269-
this.model = null!; // StrictNullOverride Nulling out ok in dispose
270-
}
271-
if (this.view !== null) {
272-
this.view.dispose();
273-
this.view = null!; // StrictNullOverride Nulling out ok in dispose
274-
}
275-
266+
this.model.dispose();
267+
this.view.dispose();
276268
this._onDidChangeFocus.dispose();
277269
this._onDidChangeSelection.dispose();
278270
this._onHighlightChange.dispose();

src/vs/base/parts/tree/browser/treeModel.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export class ItemRegistry {
192192
}
193193

194194
public dispose(): void {
195-
this.items = null!; // StrictNullOverride: nulling out ok in dispose
195+
this.items = {};
196196

197197
this._onDidRevealItem.dispose();
198198
this._onExpandItem.dispose();
@@ -1471,11 +1471,7 @@ export class TreeModel {
14711471
}
14721472

14731473
public dispose(): void {
1474-
if (this.registry) {
1475-
this.registry.dispose();
1476-
this.registry = null!; // StrictNullOverride: nulling out ok in dispose
1477-
}
1478-
1474+
this.registry.dispose();
14791475
this._onSetInput.dispose();
14801476
this._onDidSetInput.dispose();
14811477
this._onRefresh.dispose();

src/vs/base/test/browser/ui/list/rangeMap.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ suite('RangeMap', () => {
1414
rangeMap = new RangeMap();
1515
});
1616

17-
teardown(() => {
18-
rangeMap.dispose();
19-
});
20-
2117
test('intersection', () => {
2218
assert.deepEqual(Range.intersect({ start: 0, end: 0 }, { start: 0, end: 0 }), { start: 0, end: 0 });
2319
assert.deepEqual(Range.intersect({ start: 0, end: 0 }, { start: 5, end: 5 }), { start: 0, end: 0 });
@@ -346,4 +342,4 @@ suite('RangeMap', () => {
346342
assert.equal(rangeMap.positionAt(4), -1);
347343
});
348344
});
349-
});
345+
});

0 commit comments

Comments
 (0)