From 4a089131fc88ab875a1ab9597046df30d33342ff Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 23 Sep 2020 10:36:00 -0700 Subject: [PATCH] strict compile for sql/workbench/contrib/queryHistory (#12579) --- .../browser/queryHistoryDataSource.ts | 2 +- .../queryHistory/browser/queryHistoryNode.ts | 2 +- .../browser/queryHistoryRenderer.ts | 4 ++-- .../queryHistory/browser/queryHistoryView.ts | 21 ++++++++----------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/sql/workbench/contrib/queryHistory/browser/queryHistoryDataSource.ts b/src/sql/workbench/contrib/queryHistory/browser/queryHistoryDataSource.ts index 8d1bc0c0f2..7f989a51c2 100644 --- a/src/sql/workbench/contrib/queryHistory/browser/queryHistoryDataSource.ts +++ b/src/sql/workbench/contrib/queryHistory/browser/queryHistoryDataSource.ts @@ -19,7 +19,7 @@ export class QueryHistoryDataSource implements IDataSource { if (element instanceof QueryHistoryNode && element.info) { return element.info.id; } - return undefined; + return ''; } /** diff --git a/src/sql/workbench/contrib/queryHistory/browser/queryHistoryNode.ts b/src/sql/workbench/contrib/queryHistory/browser/queryHistoryNode.ts index e35c4f2f69..b38c164e71 100644 --- a/src/sql/workbench/contrib/queryHistory/browser/queryHistoryNode.ts +++ b/src/sql/workbench/contrib/queryHistory/browser/queryHistoryNode.ts @@ -15,5 +15,5 @@ export class QueryHistoryNode { public children: QueryHistoryNode[] = []; constructor( - public info: QueryHistoryInfo) { } + public info: QueryHistoryInfo | undefined) { } } diff --git a/src/sql/workbench/contrib/queryHistory/browser/queryHistoryRenderer.ts b/src/sql/workbench/contrib/queryHistory/browser/queryHistoryRenderer.ts index 929fe62a83..101e7acc27 100644 --- a/src/sql/workbench/contrib/queryHistory/browser/queryHistoryRenderer.ts +++ b/src/sql/workbench/contrib/queryHistory/browser/queryHistoryRenderer.ts @@ -42,7 +42,7 @@ export class QueryHistoryRenderer implements IRenderer { * Returns a template ID for a given element. */ public getTemplateId(tree: ITree, element: QueryHistoryNode): string { - return element.info.id; + return element.info?.id || ''; } /** @@ -63,7 +63,7 @@ export class QueryHistoryRenderer implements IRenderer { * Render a element, given an object bag returned by the template */ public renderElement(tree: ITree, element: QueryHistoryNode, templateId: string, templateData: IQueryHistoryItemTemplateData): void { - let taskStatus; + let taskStatus = ''; if (element && element.info) { templateData.icon.className = 'query-history-icon'; if (element.info.status === QueryStatus.Succeeded) { diff --git a/src/sql/workbench/contrib/queryHistory/browser/queryHistoryView.ts b/src/sql/workbench/contrib/queryHistory/browser/queryHistoryView.ts index d1d032ed25..4eefc9740f 100644 --- a/src/sql/workbench/contrib/queryHistory/browser/queryHistoryView.ts +++ b/src/sql/workbench/contrib/queryHistory/browser/queryHistoryView.ts @@ -34,8 +34,8 @@ import { IOpenerService } from 'vs/platform/opener/common/opener'; * QueryHistoryView implements the dynamic tree view for displaying Query History */ export class QueryHistoryView extends ViewPane { - private _messages: HTMLElement; - private _tree: ITree; + private _messages!: HTMLElement; + private _tree!: ITree; private _actionProvider: QueryHistoryActionProvider; constructor( @@ -87,11 +87,10 @@ export class QueryHistoryView extends ViewPane { const controller = instantiationService.createInstance(QueryHistoryController, this._actionProvider); const dnd = new DefaultDragAndDrop(); const filter = new DefaultFilter(); - const sorter = null; const accessibilityProvider = new DefaultAccessibilityProvider(); return new Tree(treeContainer, { - dataSource, renderer, controller, dnd, filter, sorter, accessibilityProvider + dataSource, renderer, controller, dnd, filter, sorter: undefined, accessibilityProvider }, { indentPixels: 10, twistiePixels: 20, @@ -103,15 +102,13 @@ export class QueryHistoryView extends ViewPane { let selectedElement: any; let targetsToExpand: any[]; - if (this._tree) { - const selection = this._tree.getSelection(); - if (selection && selection.length === 1) { - selectedElement = selection[0]; - } - // convert to old VS Code tree interface with expandable methods - const expandableTree: IExpandableTree = this._tree; - targetsToExpand = expandableTree.getExpandedElements(); + const selection = this._tree.getSelection(); + if (selection && selection.length === 1) { + selectedElement = selection[0]; } + // convert to old VS Code tree interface with expandable methods + const expandableTree: IExpandableTree = this._tree; + targetsToExpand = expandableTree.getExpandedElements(); const nodes: QueryHistoryNode[] = this.queryHistoryService.getQueryHistoryInfos().map(i => new QueryHistoryNode(i));