mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 17:23:40 -05:00
Fix a bunch of strict issues (#11857)
* fix a bunch of strict issues * fix tests * fix tests
This commit is contained in:
@@ -37,11 +37,11 @@ export default class LoadingSpinner implements OnChanges {
|
||||
}
|
||||
|
||||
@Input()
|
||||
loading: boolean;
|
||||
loading?: boolean;
|
||||
|
||||
@Input()
|
||||
loadingMessage: string;
|
||||
loadingMessage?: string;
|
||||
|
||||
@Input()
|
||||
loadingCompletedMessage: string;
|
||||
loadingCompletedMessage?: string;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ export class PanelComponent extends Disposable implements IThemable {
|
||||
private _actionbar?: ActionBar;
|
||||
private _mru: TabComponent[] = [];
|
||||
private _tabExpanded: boolean = true;
|
||||
private _styleElement: HTMLStyleElement;
|
||||
private _styleElement!: HTMLStyleElement;
|
||||
|
||||
protected AutoScrollbarVisibility = ScrollbarVisibility.Auto; // used by angular template
|
||||
protected HiddenScrollbarVisibility = ScrollbarVisibility.Hidden; // used by angular template
|
||||
@@ -266,7 +266,7 @@ export class PanelComponent extends Disposable implements IThemable {
|
||||
public updateTab(tabId: string, config: { title?: string, iconClass?: string }): void {
|
||||
// First find the tab and update it with the new values. Then manually refresh the
|
||||
// tab header since it won't detect changes made to the corresponding tab by itself.
|
||||
let tabHeader: TabHeaderComponent;
|
||||
let tabHeader: TabHeaderComponent | undefined;
|
||||
const tabHeaders = this._tabHeaders.toArray();
|
||||
const tab = this._tabs.find((item, i) => {
|
||||
if (item.identifier === tabId) {
|
||||
|
||||
@@ -25,7 +25,7 @@ export type TabType = 'tab' | 'group-header';
|
||||
export class TabComponent implements OnDestroy {
|
||||
private _child?: TabChild;
|
||||
@ContentChild(TemplateRef) templateRef!: TemplateRef<any>;
|
||||
@Input() public title!: string;
|
||||
@Input() public title?: string;
|
||||
@Input() public canClose!: boolean;
|
||||
@Input() public actions?: Array<Action>;
|
||||
@Input() public iconClass?: string;
|
||||
|
||||
@@ -102,7 +102,7 @@ export class ScrollableView extends Disposable {
|
||||
height: typeof height === 'number' ? height : DOM.getContentHeight(this.domNode)
|
||||
};
|
||||
|
||||
this.renderHeight = scrollDimensions.height;
|
||||
this.renderHeight = scrollDimensions.height!;
|
||||
|
||||
this.width = width ?? DOM.getContentWidth(this.domNode);
|
||||
|
||||
@@ -110,7 +110,7 @@ export class ScrollableView extends Disposable {
|
||||
|
||||
if (this.scrollableElementUpdateDisposable) {
|
||||
this.scrollableElementUpdateDisposable.dispose();
|
||||
this.scrollableElementUpdateDisposable = null;
|
||||
this.scrollableElementUpdateDisposable = undefined;
|
||||
scrollDimensions.scrollHeight = this.scrollHeight;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ export class ScrollableView extends Disposable {
|
||||
setScrollTop(scrollTop: number): void {
|
||||
if (this.scrollableElementUpdateDisposable) {
|
||||
this.scrollableElementUpdateDisposable.dispose();
|
||||
this.scrollableElementUpdateDisposable = null;
|
||||
this.scrollableElementUpdateDisposable = undefined;
|
||||
this.scrollableElement.setScrollDimensions({ scrollHeight: this.scrollHeight });
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export class ScrollableView extends Disposable {
|
||||
|
||||
public addViews(views: IView[]): void { // @todo anthonydresser add ability to splice into the middle of the list and remove a particular index
|
||||
const lastRenderRange = this.getRenderRange(this.lastRenderTop, this.lastRenderHeight);
|
||||
const items = views.map(view => ({ size: view.minimumSize, view, disposables: [], index: 0 }));
|
||||
const items: IItem[] = views.map(view => ({ size: view.minimumSize, view, disposables: [], index: 0 }));
|
||||
|
||||
items.map(i => i.disposables.push(i.view.onDidChange(() => this.rerender(this.getRenderRange(this.lastRenderTop, this.lastRenderHeight)))));
|
||||
|
||||
@@ -256,7 +256,7 @@ export class ScrollableView extends Disposable {
|
||||
|
||||
// DOM operations
|
||||
|
||||
private insertItemInDOM(index: number, beforeElement: HTMLElement | null): void {
|
||||
private insertItemInDOM(index: number, beforeElement: HTMLElement | undefined): void {
|
||||
const item = this.items[index];
|
||||
|
||||
if (!item.domNode) {
|
||||
@@ -298,29 +298,29 @@ export class ScrollableView extends Disposable {
|
||||
private removeItemFromDOM(index: number): void {
|
||||
const item = this.items[index];
|
||||
|
||||
if (item) {
|
||||
if (item && item.domNode) {
|
||||
item.domNode.remove();
|
||||
item.onDidInsertDisposable?.dispose();
|
||||
if (item.view.onDidRemove) {
|
||||
item.onDidRemoveDisposable = DOM.scheduleAtNextAnimationFrame(() => {
|
||||
// we don't trust the items to be performant so don't interrupt our operations
|
||||
item.view.onDidRemove();
|
||||
item.view.onDidRemove!();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getNextToLastElement(ranges: IRange[]): HTMLElement | null {
|
||||
private getNextToLastElement(ranges: IRange[]): HTMLElement | undefined {
|
||||
const lastRange = ranges[ranges.length - 1];
|
||||
|
||||
if (!lastRange) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const nextToLastItem = this.items[lastRange.end];
|
||||
|
||||
if (!nextToLastItem) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return nextToLastItem.domNode;
|
||||
@@ -333,7 +333,7 @@ export class ScrollableView extends Disposable {
|
||||
if (!this.scrollableElementUpdateDisposable) {
|
||||
this.scrollableElementUpdateDisposable = DOM.scheduleAtNextAnimationFrame(() => {
|
||||
this.scrollableElement.setScrollDimensions({ scrollHeight: this.scrollHeight });
|
||||
this.scrollableElementUpdateDisposable = null;
|
||||
this.scrollableElementUpdateDisposable = undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,9 @@ export class SelectBox extends vsSelectBox {
|
||||
let optionItems: SelectOptionItemSQL[] = SelectBox.createOptions(options);
|
||||
super(optionItems, 0, contextViewProvider, undefined, selectBoxOptions);
|
||||
|
||||
this._optionsDictionary = new Map<string, number>();
|
||||
this.populateOptionsDictionary(optionItems);
|
||||
this._dialogOptions = optionItems;
|
||||
const option = this._optionsDictionary.get(selectedOption);
|
||||
if (option) {
|
||||
super.select(option);
|
||||
@@ -144,7 +146,7 @@ export class SelectBox extends vsSelectBox {
|
||||
}
|
||||
|
||||
public populateOptionsDictionary(options: SelectOptionItemSQL[]) {
|
||||
this._optionsDictionary = new Map<string, number>();
|
||||
this._optionsDictionary.clear();
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
this._optionsDictionary.set(options[i].value, i);
|
||||
}
|
||||
@@ -198,7 +200,7 @@ export class SelectBox extends vsSelectBox {
|
||||
}
|
||||
|
||||
public get label(): string | undefined {
|
||||
return this._dialogOptions.find(s => s.value === this._selectedOption).text;
|
||||
return this._dialogOptions?.find(s => s.value === this._selectedOption)?.text;
|
||||
}
|
||||
|
||||
public get values(): string[] {
|
||||
|
||||
@@ -482,7 +482,7 @@ export class MouseController<T> implements IDisposable {
|
||||
if (document.activeElement !== e.browserEvent.target) {
|
||||
this.table.domFocus();
|
||||
}
|
||||
const merger = (lastEvent: ITableMouseEvent<T>, currentEvent: MouseEvent): ITableMouseEvent<T> => {
|
||||
const merger = (lastEvent: ITableMouseEvent<T> | null, currentEvent: MouseEvent): ITableMouseEvent<T> => {
|
||||
return this.view.toMouseEvent(currentEvent);
|
||||
};
|
||||
this._mouseMoveMonitor.startMonitoring(e.browserEvent.target as HTMLElement, e.buttons, merger, e => this.onMouseMove(e), () => this.onMouseStop());
|
||||
|
||||
@@ -27,7 +27,7 @@ export interface ButtonClickEventArgs<T extends Slick.SlickData> {
|
||||
export class ButtonColumn<T extends Slick.SlickData> implements Slick.Plugin<T> {
|
||||
private _handler = new Slick.EventHandler();
|
||||
private _definition: ButtonColumnDefinition<T>;
|
||||
private _grid: Slick.Grid<T>;
|
||||
private _grid!: Slick.Grid<T>;
|
||||
private _onClick = new Emitter<ButtonClickEventArgs<T>>();
|
||||
public onClick = this._onClick.event;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ export class TextWithIconColumn<T extends Slick.SlickData> {
|
||||
}
|
||||
private formatter(row: number, cell: number, value: any, columnDef: Slick.Column<T>, dataContext: T): string {
|
||||
const iconColumn = columnDef as TextWithIconColumnDefinition<T>;
|
||||
return `<div class="icon codicon slick-icon-cell-content ${dataContext[iconColumn.iconCssClassField]}">${value}</div>`;
|
||||
return `<div class="icon codicon slick-icon-cell-content ${iconColumn.iconCssClassField ? dataContext[iconColumn.iconCssClassField] : ''}">${value}</div>`;
|
||||
}
|
||||
|
||||
public get definition(): TextWithIconColumnDefinition<T> {
|
||||
|
||||
@@ -26,9 +26,9 @@ const defaultOptions: IActionBarOptions = {
|
||||
export class OverflowActionBar extends ActionBar {
|
||||
// Elements
|
||||
private _overflow: HTMLElement;
|
||||
private _moreItemElement: HTMLElement;
|
||||
private _moreActionsElement: HTMLElement;
|
||||
private _previousWidth: number;
|
||||
private _moreItemElement?: HTMLElement;
|
||||
private _moreActionsElement?: HTMLElement;
|
||||
private _previousWidth: number = 0;
|
||||
|
||||
constructor(container: HTMLElement, options: IActionBarOptions = defaultOptions) {
|
||||
super(container, options);
|
||||
@@ -74,7 +74,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
this.createMoreItemElement();
|
||||
}
|
||||
|
||||
this._moreItemElement.style.display = 'block';
|
||||
this._moreItemElement!.style.display = 'block';
|
||||
while (width < fullWidth) {
|
||||
let index = this._actionsList.childNodes.length - 2; // remove the last toolbar action before the more actions '...'
|
||||
if (index > -1) {
|
||||
@@ -94,7 +94,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
this.collapseItem();
|
||||
break;
|
||||
} else if (!this._overflow.hasChildNodes()) {
|
||||
this._moreItemElement.style.display = 'none';
|
||||
this._moreItemElement!.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,23 +117,26 @@ export class OverflowActionBar extends ActionBar {
|
||||
|
||||
// change role to menuItem when it's in the overflow
|
||||
if ((<HTMLElement>this._overflow.firstChild).className !== 'taskbarSeparator') {
|
||||
(<HTMLElement>this._overflow.firstChild.firstChild).setAttribute('role', 'menuItem');
|
||||
(<HTMLElement>this._overflow.firstChild!.firstChild).setAttribute('role', 'menuItem');
|
||||
}
|
||||
}
|
||||
|
||||
public restoreItem(): void {
|
||||
let item = this._overflow.removeChild(this._overflow.firstChild);
|
||||
// change role back to button when it's in the toolbar
|
||||
if ((<HTMLElement>item).className !== 'taskbarSeparator') {
|
||||
(<HTMLElement>item.firstChild).setAttribute('role', 'button');
|
||||
}
|
||||
this._actionsList.insertBefore(item, this._actionsList.lastChild);
|
||||
let firstChild = this._overflow.firstChild;
|
||||
if (firstChild) {
|
||||
let item = this._overflow.removeChild(firstChild);
|
||||
// change role back to button when it's in the toolbar
|
||||
if ((<HTMLElement>item).className !== 'taskbarSeparator') {
|
||||
(<HTMLElement>item.firstChild).setAttribute('role', 'button');
|
||||
}
|
||||
this._actionsList.insertBefore(item, this._actionsList.lastChild);
|
||||
|
||||
// move placeholder in this._items if item isn't a separator
|
||||
if (!(<HTMLElement>item).classList.contains('taskbarSeparator')) {
|
||||
let placeHolderIndex = this._items.findIndex(i => i === undefined);
|
||||
let placeHolderItem = this._items.splice(placeHolderIndex, 1);
|
||||
this._items.splice(placeHolderIndex + 1, 0, placeHolderItem[0]);
|
||||
// move placeholder in this._items if item isn't a separator
|
||||
if (!(<HTMLElement>item).classList.contains('taskbarSeparator')) {
|
||||
let placeHolderIndex = this._items.findIndex(i => i === undefined);
|
||||
let placeHolderItem = this._items.splice(placeHolderIndex, 1);
|
||||
this._items.splice(placeHolderIndex + 1, 0, placeHolderItem[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +166,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
// Close overflow if Escape is pressed
|
||||
if (event.equals(KeyCode.Escape)) {
|
||||
this.hideOverflowDisplay();
|
||||
this._moreActionsElement.focus();
|
||||
this._moreActionsElement!.focus();
|
||||
} else if (event.equals(KeyCode.UpArrow)) {
|
||||
// up arrow on first element in overflow should move focus to the bottom of the overflow
|
||||
if (this._focusedItem === this._actionsList.childElementCount) {
|
||||
@@ -192,7 +195,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
|
||||
this._moreItemElement.appendChild(this._moreActionsElement);
|
||||
this._actionsList.appendChild(this._moreItemElement);
|
||||
this._items.push(undefined); // add place holder for more item element
|
||||
this._items.push(undefined!); // add place holder for more item element @anthonydresser, im not sure how this is working, vscode indexes into this value all the time...
|
||||
}
|
||||
|
||||
public moreElementOnClick(event: MouseEvent | StandardKeyboardEvent): void {
|
||||
@@ -324,7 +327,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
if (i === this._focusedItem) {
|
||||
// placeholder for location of moreActionsElement
|
||||
if (!actionItem) {
|
||||
this._moreActionsElement.focus();
|
||||
this._moreActionsElement!.focus();
|
||||
}
|
||||
else if (types.isFunction(actionItem.focus)) {
|
||||
actionItem.focus();
|
||||
@@ -362,7 +365,7 @@ export class OverflowActionBar extends ActionBar {
|
||||
return this._overflow;
|
||||
}
|
||||
|
||||
public get focusedItem(): number {
|
||||
public get focusedItem(): number | undefined {
|
||||
return this._focusedItem;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user