Small strict null checking pass on a few files (#4293)

* fix some null checking

* fix various null strict checks

* move location fo sql files in json

* fix compile and more unused properties

* formatting

* small formatting changes

* readd types

* add comments for angular components

* formatting

* remove any decl
This commit is contained in:
Anthony Dresser
2019-03-14 18:18:32 -07:00
committed by GitHub
parent 0bf0e795ca
commit 4014c1d0ab
29 changed files with 881 additions and 1171 deletions

View File

@@ -7,7 +7,6 @@
import 'vs/css!./media/dropdownList';
import * as DOM from 'vs/base/browser/dom';
import { Dropdown, IDropdownOptions } from 'vs/base/browser/ui/dropdown/dropdown';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Color } from 'vs/base/common/color';
import { IAction } from 'vs/base/common/actions';
@@ -15,10 +14,8 @@ import { EventType as GestureEventType } from 'vs/base/browser/touch';
import { List } from 'vs/base/browser/ui/list/listWidget';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
import { Builder } from 'sql/base/browser/builder';
import { Button } from 'sql/base/browser/ui/button/button';
import { attachButtonStyler } from 'sql/platform/theme/common/styler';
import { Button, IButtonStyles } from 'sql/base/browser/ui/button/button';
export interface IDropdownStyles {
backgroundColor?: Color;
@@ -28,51 +25,49 @@ export interface IDropdownStyles {
export class DropdownList extends Dropdown {
protected backgroundColor: Color;
protected foregroundColor: Color;
protected borderColor: Color;
protected backgroundColor?: Color;
protected foregroundColor?: Color;
protected borderColor?: Color;
private button?: Button;
constructor(
container: HTMLElement,
private _options: IDropdownOptions,
private _contentContainer: HTMLElement,
private _list: List<any>,
private _themeService: IThemeService,
private _action?: IAction,
action?: IAction,
) {
super(container, _options);
if (_action) {
let button = new Button(_contentContainer);
button.label = _action.label;
this.toDispose.push(DOM.addDisposableListener(button.element, DOM.EventType.CLICK, () => {
this._action.run();
if (action) {
this.button = new Button(_contentContainer);
this.button.label = action.label;
this.toDispose.push(DOM.addDisposableListener(this.button.element, DOM.EventType.CLICK, () => {
action.run();
this.hide();
}));
this.toDispose.push(DOM.addDisposableListener(button.element, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
this.toDispose.push(DOM.addDisposableListener(this.button.element, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
let event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Enter)) {
e.stopPropagation();
this._action.run();
action.run();
this.hide();
}
}));
attachButtonStyler(button, this._themeService);
}
DOM.append(this.element, DOM.$('div.dropdown-icon'));
this.toDispose.push(new Builder(this.element).on([DOM.EventType.CLICK, DOM.EventType.MOUSE_DOWN, GestureEventType.Tap], (e: Event) => {
DOM.EventHelper.stop(e, true); // prevent default click behaviour to trigger
}).on([DOM.EventType.MOUSE_DOWN, GestureEventType.Tap], (e: Event) => {
// We want to show the context menu on dropdown so that as a user you can press and hold the
// mouse button, make a choice of action in the menu and release the mouse to trigger that
// action.
// Due to some weird bugs though, we delay showing the menu to unwind event stack
// (see https://github.com/Microsoft/vscode/issues/27648)
setTimeout(() => this.show(), 100);
}).on([DOM.EventType.KEY_DOWN], (e: KeyboardEvent) => {
let event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Enter)) {
[DOM.EventType.CLICK, DOM.EventType.MOUSE_DOWN, GestureEventType.Tap].forEach(event => {
this._register(DOM.addDisposableListener(this.element, event, e => DOM.EventHelper.stop(e, true))); // prevent default click behaviour to trigger
});
[DOM.EventType.MOUSE_DOWN, GestureEventType.Tap].forEach(event => {
this._register(DOM.addDisposableListener(this.element, event, e => setTimeout(() => this.show(), 100)));
});
this._register(DOM.addStandardDisposableListener(this.element, DOM.EventType.KEY_DOWN, (e: StandardKeyboardEvent) => {
if (e.equals(KeyCode.Enter)) {
e.stopPropagation();
setTimeout(() => {
this.show();
@@ -96,7 +91,7 @@ export class DropdownList extends Dropdown {
protected renderContents(container: HTMLElement): IDisposable {
let div = DOM.append(container, this._contentContainer);
div.style.width = DOM.getTotalWidth(this.element) + 'px';
return null;
return { dispose: () => { } };
}
/**
@@ -126,11 +121,14 @@ export class DropdownList extends Dropdown {
}
}
public style(styles: IDropdownStyles): void {
public style(styles: IDropdownStyles & IButtonStyles): void {
this.backgroundColor = styles.backgroundColor;
this.foregroundColor = styles.foregroundColor;
this.borderColor = styles.borderColor;
this.applyStyles();
if (this.button) {
this.button.style(styles);
}
}
protected applyStyles(): void {
@@ -143,7 +141,7 @@ export class DropdownList extends Dropdown {
}
}
private applyStylesOnElement(element: HTMLElement, background: string, foreground: string, border: string): void {
private applyStylesOnElement(element: HTMLElement, background: string | null, foreground: string | null, border: string | null): void {
if (element) {
element.style.backgroundColor = background;
element.style.color = foreground;
@@ -153,4 +151,4 @@ export class DropdownList extends Dropdown {
element.style.borderColor = border;
}
}
}
}