Skip to content

Commit

Permalink
remove all StrictNullOverride
Browse files Browse the repository at this point in the history
related to #78168
  • Loading branch information
joaomoreno committed Aug 30, 2019
1 parent dedf0de commit e354c8d
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 82 deletions.
56 changes: 21 additions & 35 deletions src/vs/base/browser/ui/inputbox/inputBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,7 @@ export class InputBox extends Widget {
});
}

setTimeout(() => {
if (!this.input) {
return;
}

this.updateMirror();
}, 0);
setTimeout(() => this.updateMirror(), 0);

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

public setPlaceHolder(placeHolder: string): void {
if (this.input) {
this.input.setAttribute('placeholder', placeHolder);
this.input.title = placeHolder;
}
this.input.setAttribute('placeholder', placeHolder);
this.input.title = placeHolder;
}

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

if (this.input) {
if (label) {
this.input.setAttribute('aria-label', this.ariaLabel);
} else {
this.input.removeAttribute('aria-label');
}
if (label) {
this.input.setAttribute('aria-label', this.ariaLabel);
} else {
this.input.removeAttribute('aria-label');
}
}

Expand Down Expand Up @@ -560,20 +550,18 @@ export class InputBox extends Widget {
}

protected applyStyles(): void {
if (this.element) {
const background = this.inputBackground ? this.inputBackground.toString() : null;
const foreground = this.inputForeground ? this.inputForeground.toString() : null;
const border = this.inputBorder ? this.inputBorder.toString() : null;
const background = this.inputBackground ? this.inputBackground.toString() : null;
const foreground = this.inputForeground ? this.inputForeground.toString() : null;
const border = this.inputBorder ? this.inputBorder.toString() : null;

this.element.style.backgroundColor = background;
this.element.style.color = foreground;
this.input.style.backgroundColor = background;
this.input.style.color = foreground;
this.element.style.backgroundColor = background;
this.element.style.color = foreground;
this.input.style.backgroundColor = background;
this.input.style.color = foreground;

this.element.style.borderWidth = border ? '1px' : null;
this.element.style.borderStyle = border ? 'solid' : null;
this.element.style.borderColor = border;
}
this.element.style.borderWidth = border ? '1px' : null;
this.element.style.borderStyle = border ? 'solid' : null;
this.element.style.borderColor = border;
}

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

this.element = null!; // StrictNullOverride: nulling out ok in dispose
this.input = null!; // StrictNullOverride: nulling out ok in dispose
this.contextViewProvider = undefined;
this.message = null;
this.validation = undefined;
this.state = null!; // StrictNullOverride: nulling out ok in dispose
this.actionbar = undefined;

if (this.actionbar) {
this.actionbar.dispose();
}

super.dispose();
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/list/listView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
this.domNode.appendChild(this.scrollableElement.getDomNode());
container.appendChild(this.domNode);

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

this.scrollableElement.onScroll(this.onScroll, this, this.disposables);
domEvent(this.rowsContainer, TouchEventType.Change)(this.onTouchChange, this, this.disposables);
Expand Down
4 changes: 0 additions & 4 deletions src/vs/base/browser/ui/list/rangeMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,4 @@ export class RangeMap {

return -1;
}

dispose() {
this.groups = null!; // StrictNullOverride: nulling out ok in dispose
}
}
14 changes: 2 additions & 12 deletions src/vs/base/browser/ui/list/rowCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ export class RowCache<T> implements IDisposable {
return result;
}

private garbageCollect(): void {
if (!this.renderers) {
return;
}

dispose(): void {
this.cache.forEach((cachedRows, templateId) => {
for (const cachedRow of cachedRows) {
const renderer = this.getRenderer(templateId);
Expand All @@ -96,17 +92,11 @@ export class RowCache<T> implements IDisposable {
this.cache.clear();
}

dispose(): void {
this.garbageCollect();
this.cache.clear();
this.renderers = null!; // StrictNullOverride: nulling out ok in dispose
}

private getRenderer(templateId: string): IListRenderer<T, any> {
const renderer = this.renderers.get(templateId);
if (!renderer) {
throw new Error(`No renderer found for ${templateId}`);
}
return renderer;
}
}
}
7 changes: 1 addition & 6 deletions src/vs/base/browser/ui/sash/sash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,6 @@ export class Sash extends Disposable {

dispose(): void {
super.dispose();

if (this.el && this.el.parentElement) {
this.el.parentElement.removeChild(this.el);
}

this.el = null!; // StrictNullOverride: nulling out ok in dispose
this.el.remove();
}
}
18 changes: 5 additions & 13 deletions src/vs/base/parts/tree/browser/treeImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ export class Tree implements _.ITree {
}

get onDidFocus(): Event<void> {
return this.view && this.view.onDOMFocus;
return this.view.onDOMFocus;
}

get onDidBlur(): Event<void> {
return this.view && this.view.onDOMBlur;
return this.view.onDOMBlur;
}

get onDidScroll(): Event<void> {
return this.view && this.view.onDidScroll;
return this.view.onDidScroll;
}

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

public dispose(): void {
this._onDispose.fire();

if (this.model !== null) {
this.model.dispose();
this.model = null!; // StrictNullOverride Nulling out ok in dispose
}
if (this.view !== null) {
this.view.dispose();
this.view = null!; // StrictNullOverride Nulling out ok in dispose
}

this.model.dispose();
this.view.dispose();
this._onDidChangeFocus.dispose();
this._onDidChangeSelection.dispose();
this._onHighlightChange.dispose();
Expand Down
8 changes: 2 additions & 6 deletions src/vs/base/parts/tree/browser/treeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class ItemRegistry {
}

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

this._onDidRevealItem.dispose();
this._onExpandItem.dispose();
Expand Down Expand Up @@ -1471,11 +1471,7 @@ export class TreeModel {
}

public dispose(): void {
if (this.registry) {
this.registry.dispose();
this.registry = null!; // StrictNullOverride: nulling out ok in dispose
}

this.registry.dispose();
this._onSetInput.dispose();
this._onDidSetInput.dispose();
this._onRefresh.dispose();
Expand Down
6 changes: 1 addition & 5 deletions src/vs/base/test/browser/ui/list/rangeMap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ suite('RangeMap', () => {
rangeMap = new RangeMap();
});

teardown(() => {
rangeMap.dispose();
});

test('intersection', () => {
assert.deepEqual(Range.intersect({ start: 0, end: 0 }, { start: 0, end: 0 }), { start: 0, end: 0 });
assert.deepEqual(Range.intersect({ start: 0, end: 0 }, { start: 5, end: 5 }), { start: 0, end: 0 });
Expand Down Expand Up @@ -346,4 +342,4 @@ suite('RangeMap', () => {
assert.equal(rangeMap.positionAt(4), -1);
});
});
});
});

0 comments on commit e354c8d

Please sign in to comment.