From 64929de09d9d114af54eb1ef54c4ec8db624b004 Mon Sep 17 00:00:00 2001 From: Anthony Dresser Date: Mon, 27 Jan 2020 16:26:49 -0800 Subject: [PATCH] Add more folders to strict compile (#8954) * add more folders to strictire compile, add more strict compile options * update ci * remove unnecessary assertion --- .github/workflows/ci.yml | 12 +- .vscode/tasks.json | 6 +- .../darwin/continuous-build-darwin.yml | 2 +- .../linux/continuous-build-linux.yml | 2 +- build/azure-pipelines/sql-product-compile.yml | 2 +- .../win32/continuous-build-win32.yml | 2 +- package.json | 4 +- src/sql/azdata.d.ts | 2 +- .../browser/ui/checkbox/checkbox.component.ts | 6 +- src/sql/base/browser/ui/inputBox/inputBox.ts | 2 +- src/sql/base/browser/ui/listBox/listBox.ts | 6 +- .../base/browser/ui/panel/panel.component.ts | 23 ++- src/sql/base/browser/ui/panel/panel.ts | 10 +- .../base/browser/ui/panel/tab.component.ts | 14 +- .../browser/ui/panel/tabHeader.component.ts | 14 +- .../ui/scrollable/scrollable.directive.ts | 10 +- .../scrollableSplitview.ts | 30 +-- .../base/browser/ui/selectBox/selectBox.ts | 14 +- .../base/browser/ui/table/asyncDataView.ts | 2 +- src/sql/base/browser/ui/table/formatters.ts | 6 +- .../plugins/additionalKeyBindings.plugin.ts | 2 +- .../table/plugins/autoSizeColumns.plugin.ts | 8 +- .../ui/table/plugins/cellRangeSelector.ts | 10 +- .../plugins/cellSelectionModel.plugin.ts | 2 +- .../plugins/checkboxSelectColumn.plugin.ts | 6 +- .../ui/table/plugins/copyKeybind.plugin.ts | 2 +- .../ui/table/plugins/headerFilter.plugin.ts | 16 +- .../plugins/mousewheelTableScroll.plugin.ts | 4 +- .../browser/ui/table/plugins/rowDetailView.ts | 4 +- .../table/plugins/rowNumberColumn.plugin.ts | 2 +- .../table/plugins/rowSelectionModel.plugin.ts | 2 +- src/sql/base/browser/ui/table/table.ts | 6 +- .../base/browser/ui/table/tableDataView.ts | 24 +-- src/sql/base/common/promise.ts | 4 +- .../editableDropdown/browser/dropdown.ts | 2 +- .../editableDropdown/browser/dropdownTree.ts | 10 +- .../browser/ui/table/gridFormatters.test.ts | 7 +- .../browser/ui/table/tableDataView.test.ts | 2 +- src/sql/base/test/common/event.ts | 6 +- .../accounts/common/accountActions.ts | 2 +- .../platform/accounts/common/accountStore.ts | 4 +- .../accounts/common/firewallRuleViewModel.ts | 24 +-- .../accounts/test/common/accountStore.test.ts | 18 +- .../editableDropdown.component.ts | 8 +- .../browser/inputbox/inputBox.component.ts | 22 +-- .../browser/selectBox/selectBox.component.ts | 10 +- .../common/connectionManagementInfo.ts | 30 ++- .../connection/common/connectionProfile.ts | 4 +- .../common/connectionProfileGroup.ts | 14 +- .../common/connectionStatusManager.ts | 17 +- .../platform/connection/common/interfaces.ts | 2 +- .../common/providerConnectionInfo.ts | 44 ++--- .../test/common/connectionConfig.test.ts | 174 +++++++++--------- .../test/common/connectionProfile.test.ts | 68 +++---- .../common/connectionProfileGroup.test.ts | 4 +- .../test/common/connectionStore.test.ts | 72 ++++---- .../common/providerConnectionInfo.test.ts | 86 ++++----- .../test/common/testConfigurationService.ts | 4 +- .../common/testConnectionManagementService.ts | 83 ++++----- .../test/common/testConnectionProvider.ts | 16 +- .../test/node/connectionStatusManager.test.ts | 74 ++++---- .../credentials/common/credentialsService.ts | 8 +- .../test/common/testCredentialsService.ts | 2 +- .../dashboard/browser/dashboardViewService.ts | 6 +- .../dashboard/browser/insightRegistry.ts | 2 +- .../browser/modelComponentRegistry.ts | 4 +- .../dashboard/browser/widgetRegistry.ts | 10 +- .../platform/tasks/browser/tasksRegistry.ts | 1 - src/sql/platform/tasks/common/tasksNode.ts | 10 +- src/sql/platform/tasks/common/tasksService.ts | 10 +- .../workbench/api/common/sqlExtHostTypes.ts | 4 +- .../contrib/charts/browser/interfaces.ts | 4 +- .../contrib/charts/common/interfaces.ts | 2 +- .../propertiesWidget.component.test.ts | 6 +- .../browser/connectionTreeActions.test.ts | 2 +- .../fileBrowser/common/fileBrowserTree.ts | 8 +- .../services/fileBrowser/common/fileNode.ts | 4 +- src/tsconfig.strictNullChecks.json | 44 ----- src/tsconfig.vscode.json | 38 ++++ src/typings/slickgrid.d.ts | 39 ++-- src/vs/base/browser/ui/inputbox/inputBox.ts | 2 +- 81 files changed, 630 insertions(+), 644 deletions(-) delete mode 100644 src/tsconfig.strictNullChecks.json create mode 100644 src/tsconfig.vscode.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95a618841a..78a4f04991 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,8 +37,8 @@ jobs: # name: Download Electron # - run: yarn gulp hygiene # name: Run Hygiene Checks - # - run: yarn strict-null-check # {{SQL CARBON EDIT}} add step - # name: Run Strict Null Check + # - run: yarn strict-vscode # {{SQL CARBON EDIT}} add step + # name: Run Strict Compile Options # # - run: yarn monaco-compile-check {{SQL CARBON EDIT}} remove step # # name: Run Monaco Editor Checks # - run: yarn valid-layers-check @@ -71,8 +71,8 @@ jobs: name: Download Electron - run: yarn gulp hygiene name: Run Hygiene Checks - - run: yarn strict-null-check # {{SQL CARBON EDIT}} add step - name: Run Strict Null Check + - run: yarn strict-vscode # {{SQL CARBON EDIT}} add step + name: Run Strict Compile Options # - run: yarn monaco-compile-check {{SQL CARBON EDIT}} remove step # name: Run Monaco Editor Checks - run: yarn valid-layers-check @@ -102,8 +102,8 @@ jobs: name: Download Electron - run: yarn gulp hygiene name: Run Hygiene Checks - - run: yarn strict-null-check # {{SQL CARBON EDIT}} add step - name: Run Strict Null Check + - run: yarn strict-vscode # {{SQL CARBON EDIT}} add step + name: Run Strict Compile Options # - run: yarn monaco-compile-check {{SQL CARBON EDIT}} remove step # name: Run Monaco Editor Checks - run: yarn valid-layers-check diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2c9774d518..880b2e95f4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -47,15 +47,15 @@ }, { "type": "npm", - "script": "strict-null-check-watch", - "label": "TS - Strict Null Checks", + "script": "strict-vscode-watch", + "label": "TS - Strict VSCode", "isBackground": true, "presentation": { "reveal": "never" }, "problemMatcher": { "base": "$tsc-watch", - "owner": "typescript-strict-null-checks", + "owner": "typescript-vscode", "applyTo": "allDocuments" } }, diff --git a/build/azure-pipelines/darwin/continuous-build-darwin.yml b/build/azure-pipelines/darwin/continuous-build-darwin.yml index 0ef09deaab..409f8631af 100644 --- a/build/azure-pipelines/darwin/continuous-build-darwin.yml +++ b/build/azure-pipelines/darwin/continuous-build-darwin.yml @@ -27,7 +27,7 @@ steps: yarn gulp hygiene displayName: Run Hygiene Checks - script: | # {{SQL CARBON EDIT}} add step - yarn strict-null-check + yarn strict-vscode displayName: Run Strict Null Check. # - script: | {{SQL CARBON EDIT}} remove step # yarn monaco-compile-check diff --git a/build/azure-pipelines/linux/continuous-build-linux.yml b/build/azure-pipelines/linux/continuous-build-linux.yml index b62a8d768c..a661b9e5d5 100644 --- a/build/azure-pipelines/linux/continuous-build-linux.yml +++ b/build/azure-pipelines/linux/continuous-build-linux.yml @@ -35,7 +35,7 @@ steps: yarn gulp hygiene displayName: Run Hygiene Checks - script: | # {{SQL CARBON EDIT}} add strict null check - yarn strict-null-check + yarn strict-vscode displayName: Run Strict Null Check # - script: | {{SQL CARBON EDIT}} remove monaco editor checks # yarn monaco-compile-check diff --git a/build/azure-pipelines/sql-product-compile.yml b/build/azure-pipelines/sql-product-compile.yml index 66f004f68f..9a2d73f91a 100644 --- a/build/azure-pipelines/sql-product-compile.yml +++ b/build/azure-pipelines/sql-product-compile.yml @@ -88,7 +88,7 @@ steps: - script: | set -e yarn gulp hygiene - yarn strict-null-check + yarn strict-vscode yarn valid-layers-check displayName: Run hygiene, tslint condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) diff --git a/build/azure-pipelines/win32/continuous-build-win32.yml b/build/azure-pipelines/win32/continuous-build-win32.yml index ecb243ee56..a7938ffb47 100644 --- a/build/azure-pipelines/win32/continuous-build-win32.yml +++ b/build/azure-pipelines/win32/continuous-build-win32.yml @@ -32,7 +32,7 @@ steps: yarn gulp hygiene displayName: Run Hygiene Checks - script: | # {{SQL CARBON EDIT}} add step - yarn strict-null-check + yarn strict-vscode displayName: Run Strict Null Check # - powershell: | {{SQL CARBON EDIT}} remove step # yarn monaco-compile-check diff --git a/package.json b/package.json index 1963abca5d..bae345e99f 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ "update-localization-extension": "node build/npm/update-localization-extension.js", "smoketest": "cd test/smoke && node test/index.js", "monaco-compile-check": "tsc -p src/tsconfig.monaco.json --noEmit", - "strict-null-check": "node node_modules/typescript/bin/tsc -p src/tsconfig.strictNullChecks.json", - "strict-null-check-watch": "node node_modules/typescript/bin/tsc -p src/tsconfig.strictNullChecks.json --watch", + "strict-vscode": "node node_modules/typescript/bin/tsc -p src/tsconfig.vscode.json", + "strict-vscode-watch": "node node_modules/typescript/bin/tsc -p src/tsconfig.vscode.json --watch", "strict-initialization-watch": "tsc --watch -p src/tsconfig.json --noEmit --strictPropertyInitialization", "valid-layers-check": "node build/lib/layersChecker.js", "strict-function-types-watch": "tsc --watch -p src/tsconfig.json --noEmit --strictFunctionTypes", diff --git a/src/sql/azdata.d.ts b/src/sql/azdata.d.ts index 536d427e67..a876fced61 100644 --- a/src/sql/azdata.d.ts +++ b/src/sql/azdata.d.ts @@ -328,7 +328,7 @@ declare module 'azdata' { authenticationType: string; savePassword: boolean; groupFullName?: string; - groupId: string; + groupId?: string; providerName: string; saveProfile: boolean; id: string; diff --git a/src/sql/base/browser/ui/checkbox/checkbox.component.ts b/src/sql/base/browser/ui/checkbox/checkbox.component.ts index a13d0874ca..6958143ad4 100644 --- a/src/sql/base/browser/ui/checkbox/checkbox.component.ts +++ b/src/sql/base/browser/ui/checkbox/checkbox.component.ts @@ -15,14 +15,14 @@ import { Checkbox as sqlCheckbox } from 'sql/base/browser/ui/checkbox/checkbox'; template: '' }) export class Checkbox implements OnInit, OnChanges { - @Input() label: string; + @Input() label!: string; @Input() enabled = true; @Input() checked = true; - @Input('aria-label') private ariaLabel: string; + @Input('aria-label') private ariaLabel?: string; @Output() onChange = new EventEmitter(); - private _checkbox: sqlCheckbox; + private _checkbox?: sqlCheckbox; constructor( @Inject(forwardRef(() => ElementRef)) private _el: ElementRef diff --git a/src/sql/base/browser/ui/inputBox/inputBox.ts b/src/sql/base/browser/ui/inputBox/inputBox.ts index b8c4c0f01f..421fec5b5a 100644 --- a/src/sql/base/browser/ui/inputBox/inputBox.ts +++ b/src/sql/base/browser/ui/inputBox/inputBox.ts @@ -31,7 +31,7 @@ export class InputBox extends vsInputBox { private _onLoseFocus = this._register(new Emitter()); public onLoseFocus: Event = this._onLoseFocus.event; - private _isTextAreaInput: boolean; + private _isTextAreaInput = false; private _hideErrors = false; constructor(container: HTMLElement, contextViewProvider: IContextViewProvider, options?: IInputOptions) { diff --git a/src/sql/base/browser/ui/listBox/listBox.ts b/src/sql/base/browser/ui/listBox/listBox.ts index bde535d157..85fede58b5 100644 --- a/src/sql/base/browser/ui/listBox/listBox.ts +++ b/src/sql/base/browser/ui/listBox/listBox.ts @@ -60,11 +60,11 @@ export class ListBox extends SelectBox { this.contextViewProvider = contextViewProvider; this.isValid = true; this.selectElement.multiple = true; - this.selectElement.style['height'] = '80px'; + this.selectElement.style.height = '80px'; // Set width style for horizontal scrollbar - this.selectElement.style['width'] = 'inherit'; - this.selectElement.style['min-width'] = '100%'; + this.selectElement.style.width = 'inherit'; + this.selectElement.style.minWidth = '100%'; this._register(dom.addStandardDisposableListener(this.selectElement, dom.EventType.KEY_DOWN, (e: StandardKeyboardEvent) => this._onKeyDown.fire(e))); diff --git a/src/sql/base/browser/ui/panel/panel.component.ts b/src/sql/base/browser/ui/panel/panel.component.ts index 58e02334a6..4ac6ddaf18 100644 --- a/src/sql/base/browser/ui/panel/panel.component.ts +++ b/src/sql/base/browser/ui/panel/panel.component.ts @@ -68,30 +68,29 @@ let idPool = 0; ` }) export class PanelComponent extends Disposable { - @Input() public options: IPanelOptions; - @Input() public actions: Array; - @ContentChildren(TabComponent) private _tabs: QueryList; - @ViewChild(ScrollableDirective) private scrollable: ScrollableDirective; + @Input() public options?: IPanelOptions; + @Input() public actions?: Array; + @ContentChildren(TabComponent) private readonly _tabs!: QueryList; + @ViewChild(ScrollableDirective) private scrollable?: ScrollableDirective; @Output() public onTabChange = new EventEmitter(); @Output() public onTabClose = new EventEmitter(); - private _activeTab: TabComponent; - private _actionbar: ActionBar; - private _mru: TabComponent[]; + private _activeTab?: TabComponent; + private _actionbar?: ActionBar; + private _mru: TabComponent[] = []; protected AutoScrollbarVisibility = ScrollbarVisibility.Auto; // used by angular template protected HiddenScrollbarVisibility = ScrollbarVisibility.Hidden; // used by angular template protected NavigationBarLayout = NavigationBarLayout; // used by angular template - @ViewChild('panelActionbar', { read: ElementRef }) private _actionbarRef: ElementRef; + @ViewChild('panelActionbar', { read: ElementRef }) private _actionbarRef!: ElementRef; constructor(@Inject(forwardRef(() => NgZone)) private _zone: NgZone) { super(); } ngOnInit(): void { this.options = mixin(this.options || {}, defaultOptions, false); - this._mru = []; } ngAfterContentInit(): void { @@ -195,8 +194,8 @@ export class PanelComponent extends Disposable { /** * Get the id of the active tab */ - public get getActiveTab(): string { - return this._activeTab.identifier; + public get getActiveTab(): string | undefined { + return this._activeTab?.identifier; } /** @@ -244,6 +243,6 @@ export class PanelComponent extends Disposable { } public layout() { - this._activeTab.layout(); + this._activeTab?.layout(); } } diff --git a/src/sql/base/browser/ui/panel/panel.ts b/src/sql/base/browser/ui/panel/panel.ts index afec828fd0..85921f09d3 100644 --- a/src/sql/base/browser/ui/panel/panel.ts +++ b/src/sql/base/browser/ui/panel/panel.ts @@ -69,7 +69,7 @@ export class TabbedPanel extends Disposable { private body: HTMLElement; private parent: HTMLElement; private _actionbar: ActionBar; - private _currentDimensions: DOM.Dimension; + private _currentDimensions?: DOM.Dimension; private _collapsed = false; private _headerVisible: boolean; private _styleElement: HTMLStyleElement; @@ -130,7 +130,9 @@ export class TabbedPanel extends Disposable { if (this._tabMap.size > 1 && !this._headerVisible) { this.parent.insertBefore(this.header, this.parent.firstChild); this._headerVisible = true; - this.layout(this._currentDimensions); + if (this._currentDimensions) { + this.layout(this._currentDimensions); + } } return tab.identifier as PanelTabIdentifier; } @@ -287,7 +289,9 @@ export class TabbedPanel extends Disposable { if (!this.options.showHeaderWhenSingleView && this._tabMap.size === 1 && this._headerVisible) { this.header.remove(); this._headerVisible = false; - this.layout(this._currentDimensions); + if (this._currentDimensions) { + this.layout(this._currentDimensions); + } } } diff --git a/src/sql/base/browser/ui/panel/tab.component.ts b/src/sql/base/browser/ui/panel/tab.component.ts index 6ff5dd53c5..745199c23e 100644 --- a/src/sql/base/browser/ui/panel/tab.component.ts +++ b/src/sql/base/browser/ui/panel/tab.component.ts @@ -21,14 +21,14 @@ export abstract class TabChild extends Disposable { ` }) export class TabComponent implements OnDestroy { - private _child: TabChild; - @ContentChild(TemplateRef) templateRef: TemplateRef; - @Input() public title: string; - @Input() public canClose: boolean; - @Input() public actions: Array; - @Input() public iconClass: string; + private _child?: TabChild; + @ContentChild(TemplateRef) templateRef!: TemplateRef; + @Input() public title!: string; + @Input() public canClose!: boolean; + @Input() public actions?: Array; + @Input() public iconClass?: string; public _active = false; - @Input() public identifier: string; + @Input() public identifier!: string; @Input() private visibilityType: 'if' | 'visibility' = 'if'; private rendered = false; private destroyed: boolean = false; diff --git a/src/sql/base/browser/ui/panel/tabHeader.component.ts b/src/sql/base/browser/ui/panel/tabHeader.component.ts index 3f6dba382d..a10ad3e4d5 100644 --- a/src/sql/base/browser/ui/panel/tabHeader.component.ts +++ b/src/sql/base/browser/ui/panel/tabHeader.component.ts @@ -29,17 +29,17 @@ import { CloseTabAction } from 'sql/base/browser/ui/panel/tabActions'; ` }) export class TabHeaderComponent extends Disposable implements AfterContentInit, OnDestroy { - @Input() public tab: TabComponent; - @Input() public showIcon: boolean; - @Input() public active: boolean; + @Input() public tab!: TabComponent; + @Input() public showIcon?: boolean; + @Input() public active?: boolean; @Output() public onSelectTab: EventEmitter = new EventEmitter(); @Output() public onCloseTab: EventEmitter = new EventEmitter(); - private _actionbar: ActionBar; + private _actionbar!: ActionBar; - @ViewChild('actionHeader', { read: ElementRef }) private _actionHeaderRef: ElementRef; - @ViewChild('actionbar', { read: ElementRef }) private _actionbarRef: ElementRef; - @ViewChild('tabLabel', { read: ElementRef }) private _tabLabelRef: ElementRef; + @ViewChild('actionHeader', { read: ElementRef }) private _actionHeaderRef!: ElementRef; + @ViewChild('actionbar', { read: ElementRef }) private _actionbarRef!: ElementRef; + @ViewChild('tabLabel', { read: ElementRef }) private _tabLabelRef!: ElementRef; constructor() { super(); } diff --git a/src/sql/base/browser/ui/scrollable/scrollable.directive.ts b/src/sql/base/browser/ui/scrollable/scrollable.directive.ts index f58a16e45b..70933ad7f2 100644 --- a/src/sql/base/browser/ui/scrollable/scrollable.directive.ts +++ b/src/sql/base/browser/ui/scrollable/scrollable.directive.ts @@ -14,11 +14,11 @@ import { AngularDisposable } from 'sql/base/browser/lifecycle'; selector: '[scrollable]' }) export class ScrollableDirective extends AngularDisposable { - private scrollableElement: ScrollableElement; - private parent: HTMLElement; - private scrolled: HTMLElement; - @Input() horizontalScroll: ScrollbarVisibility; - @Input() verticalScroll: ScrollbarVisibility; + private scrollableElement!: ScrollableElement; + private parent!: HTMLElement; + private scrolled!: HTMLElement; + @Input() horizontalScroll?: ScrollbarVisibility; + @Input() verticalScroll?: ScrollbarVisibility; @Input() useShadow = false; @Input() scrollYToX = false; diff --git a/src/sql/base/browser/ui/scrollableSplitview/scrollableSplitview.ts b/src/sql/base/browser/ui/scrollableSplitview/scrollableSplitview.ts index 3c4d1af1bf..5490159d90 100644 --- a/src/sql/base/browser/ui/scrollableSplitview/scrollableSplitview.ts +++ b/src/sql/base/browser/ui/scrollableSplitview/scrollableSplitview.ts @@ -121,12 +121,12 @@ export class ScrollableSplitView extends HeightMap implements IDisposable { private proportions: undefined | number[] = undefined; private viewItems: IViewItem[] = []; private sashItems: ISashItem[] = []; - private sashDragState: ISashDragState; + private sashDragState?: ISashDragState; private state: State = State.Idle; private inverseAltBehavior: boolean; - private lastRenderHeight: number; - private lastRenderTop: number; + private lastRenderHeight?: number; + private lastRenderTop?: number; private options: ISplitViewOptions; @@ -317,8 +317,8 @@ export class ScrollableSplitView extends HeightMap implements IDisposable { // Re-render the views. Set lastRenderTop and lastRenderHeight to undefined since // this isn't actually scrolling up or down - let scrollTop = this.lastRenderTop; - let viewHeight = this.lastRenderHeight; + let scrollTop = this.lastRenderTop!; + let viewHeight = this.lastRenderHeight!; this.lastRenderTop = 0; this.lastRenderHeight = 0; this.render(scrollTop, viewHeight); @@ -528,8 +528,8 @@ export class ScrollableSplitView extends HeightMap implements IDisposable { // This way, we can press Alt while we resize a sash, macOS style! const disposable = combinedDisposable( - domEvent(document.body, 'keydown')(e => resetSashDragState(this.sashDragState.current, e.altKey)), - domEvent(document.body, 'keyup')(() => resetSashDragState(this.sashDragState.current, false)) + domEvent(document.body, 'keydown')(e => resetSashDragState(this.sashDragState!.current, e.altKey)), + domEvent(document.body, 'keyup')(() => resetSashDragState(this.sashDragState!.current, false)) ); const resetSashDragState = (start: number, alt: boolean) => { @@ -565,8 +565,8 @@ export class ScrollableSplitView extends HeightMap implements IDisposable { } private onSashChange({ current }: ISashEvent): void { - const { index, start, sizes, alt, minDelta, maxDelta } = this.sashDragState; - this.sashDragState.current = current; + const { index, start, sizes, alt, minDelta, maxDelta } = this.sashDragState!; + this.sashDragState!.current = current; const delta = current - start; const newDelta = this.resize(index, delta, sizes, undefined, undefined, minDelta, maxDelta); @@ -589,7 +589,7 @@ export class ScrollableSplitView extends HeightMap implements IDisposable { private onSashEnd(index: number): void { this._onDidSashChange.fire(index); - this.sashDragState.disposable.dispose(); + this.sashDragState!.disposable.dispose(); this.saveProportions(); } @@ -686,7 +686,7 @@ export class ScrollableSplitView extends HeightMap implements IDisposable { let renderTop = scrollTop; let renderBottom = scrollTop + viewHeight; - let thisRenderBottom = this.lastRenderTop + this.lastRenderHeight; + let thisRenderBottom = this.lastRenderTop! + this.lastRenderHeight!; // when view scrolls down, start rendering from the renderBottom for (i = this.indexAfter(renderBottom) - 1, stop = this.indexAt(Math.max(thisRenderBottom, renderTop)); i >= stop; i--) { @@ -696,21 +696,21 @@ export class ScrollableSplitView extends HeightMap implements IDisposable { } // when view scrolls up, start rendering from either this.renderTop or renderBottom - for (i = Math.min(this.indexAt(this.lastRenderTop), this.indexAfter(renderBottom)) - 1, stop = this.indexAt(renderTop); i >= stop; i--) { + for (i = Math.min(this.indexAt(this.lastRenderTop!), this.indexAfter(renderBottom)) - 1, stop = this.indexAt(renderTop); i >= stop; i--) { if (this.insertItemInDOM(this.itemAtIndex(i))) { this.dirtyState = true; } } // when view scrolls down, start unrendering from renderTop - for (i = this.indexAt(this.lastRenderTop), stop = Math.min(this.indexAt(renderTop), this.indexAfter(thisRenderBottom)); i < stop; i++) { + for (i = this.indexAt(this.lastRenderTop!), stop = Math.min(this.indexAt(renderTop), this.indexAfter(thisRenderBottom)); i < stop; i++) { if (this.removeItemFromDOM(this.itemAtIndex(i))) { this.dirtyState = true; } } // when view scrolls up, start unrendering from either renderBottom this.renderTop - for (i = Math.max(this.indexAfter(renderBottom), this.indexAt(this.lastRenderTop)), stop = this.indexAfter(thisRenderBottom); i < stop; i++) { + for (i = Math.max(this.indexAfter(renderBottom), this.indexAt(this.lastRenderTop!)), stop = this.indexAfter(thisRenderBottom); i < stop; i++) { if (this.removeItemFromDOM(this.itemAtIndex(i))) { this.dirtyState = true; } @@ -854,7 +854,7 @@ export class ScrollableSplitView extends HeightMap implements IDisposable { this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0); if (this.dirtyState) { - for (let i = this.indexAt(this.lastRenderTop); i <= this.indexAfter(this.lastRenderTop + this.lastRenderHeight) - 1; i++) { + for (let i = this.indexAt(this.lastRenderTop!); i <= this.indexAfter(this.lastRenderTop! + this.lastRenderHeight!) - 1; i++) { this.viewItems[i].layout(); if (this.options.enableResizing) { this.sashItems[i].sash.layout(); diff --git a/src/sql/base/browser/ui/selectBox/selectBox.ts b/src/sql/base/browser/ui/selectBox/selectBox.ts index 0a921974a4..b0afca8f5f 100644 --- a/src/sql/base/browser/ui/selectBox/selectBox.ts +++ b/src/sql/base/browser/ui/selectBox/selectBox.ts @@ -58,9 +58,7 @@ export class SelectBox extends vsSelectBox { private inputValidationErrorBackground?: Color; private inputValidationErrorForeground?: Color; - private element: HTMLElement; - - + private element?: HTMLElement; constructor(options: string[], selectedOption: string, contextViewProvider: IContextViewProvider, container?: HTMLElement, selectBoxOptions?: ISelectBoxOptions) { super(options.map(option => { return { text: option }; }), 0, contextViewProvider, undefined, selectBoxOptions); @@ -261,10 +259,12 @@ export class SelectBox extends vsSelectBox { } public hideMessage(): void { - dom.removeClass(this.element, 'info'); - dom.removeClass(this.element, 'warning'); - dom.removeClass(this.element, 'error'); - dom.addClass(this.element, 'idle'); + if (this.element) { + dom.removeClass(this.element, 'info'); + dom.removeClass(this.element, 'warning'); + dom.removeClass(this.element, 'error'); + dom.addClass(this.element, 'idle'); + } this._hideMessage(); this.applyStyles(); diff --git a/src/sql/base/browser/ui/table/asyncDataView.ts b/src/sql/base/browser/ui/table/asyncDataView.ts index d6b15d2550..f037e5b82e 100644 --- a/src/sql/base/browser/ui/table/asyncDataView.ts +++ b/src/sql/base/browser/ui/table/asyncDataView.ts @@ -80,7 +80,7 @@ export class VirtualizedCollection implements IObserv private _bufferWindowAfter: DataWindow; private _lengthChanged = false; - private collectionChangedCallback: (startIndex: number, count: number) => void; + private collectionChangedCallback?: (startIndex: number, count: number) => void; constructor( private readonly windowSize: number, diff --git a/src/sql/base/browser/ui/table/formatters.ts b/src/sql/base/browser/ui/table/formatters.ts index c9c5f3f01b..9bbf83c9be 100644 --- a/src/sql/base/browser/ui/table/formatters.ts +++ b/src/sql/base/browser/ui/table/formatters.ts @@ -6,11 +6,13 @@ import { escape } from 'sql/base/common/strings'; import { localize } from 'vs/nls'; -export class DBCellValue { +export interface DBCellValue { displayValue: string; isNull: boolean; +} - public static isDBCellValue(object: any): boolean { +export namespace DBCellValue { + export function isDBCellValue(object: any): boolean { return (object !== undefined && object.displayValue !== undefined && object.isNull !== undefined); } } diff --git a/src/sql/base/browser/ui/table/plugins/additionalKeyBindings.plugin.ts b/src/sql/base/browser/ui/table/plugins/additionalKeyBindings.plugin.ts index 3e15f8f70d..48bed7e1a3 100644 --- a/src/sql/base/browser/ui/table/plugins/additionalKeyBindings.plugin.ts +++ b/src/sql/base/browser/ui/table/plugins/additionalKeyBindings.plugin.ts @@ -10,7 +10,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; * Implements the various additional navigation keybindings we want out of slickgrid */ export class AdditionalKeyBindings implements Slick.Plugin { - private grid: Slick.Grid; + private grid!: Slick.Grid; private handler = new Slick.EventHandler(); public init(grid: Slick.Grid) { diff --git a/src/sql/base/browser/ui/table/plugins/autoSizeColumns.plugin.ts b/src/sql/base/browser/ui/table/plugins/autoSizeColumns.plugin.ts index 6361a6dca0..4b1b171b7f 100644 --- a/src/sql/base/browser/ui/table/plugins/autoSizeColumns.plugin.ts +++ b/src/sql/base/browser/ui/table/plugins/autoSizeColumns.plugin.ts @@ -14,10 +14,10 @@ const defaultOptions: IAutoColumnSizeOptions = { autoSizeOnRender: false }; -export class AutoColumnSize implements Slick.Plugin { - private _grid: Slick.Grid; - private _$container: JQuery; - private _context: CanvasRenderingContext2D; +export class AutoColumnSize implements Slick.Plugin { + private _grid!: Slick.Grid; + private _$container!: JQuery; + private _context!: CanvasRenderingContext2D; private _options: IAutoColumnSizeOptions; private onPostEventHandler = new Slick.EventHandler(); diff --git a/src/sql/base/browser/ui/table/plugins/cellRangeSelector.ts b/src/sql/base/browser/ui/table/plugins/cellRangeSelector.ts index 3f8445039c..7cf029411e 100644 --- a/src/sql/base/browser/ui/table/plugins/cellRangeSelector.ts +++ b/src/sql/base/browser/ui/table/plugins/cellRangeSelector.ts @@ -37,12 +37,12 @@ export interface ICellRangeDecorator { } export class CellRangeSelector implements ICellRangeSelector { - private grid: Slick.Grid; - private dragging: boolean; + private grid!: Slick.Grid; + private dragging?: boolean; private handler = new Slick.EventHandler(); - private decorator: ICellRangeDecorator; - private canvas: HTMLCanvasElement; - private currentlySelectedRange: { start: Slick.Cell, end?: Slick.Cell }; + private decorator!: ICellRangeDecorator; + private canvas!: HTMLCanvasElement; + private currentlySelectedRange?: { start: Slick.Cell, end?: Slick.Cell }; public onBeforeCellRangeSelected = new Slick.Event(); public onCellRangeSelected = new Slick.Event(); diff --git a/src/sql/base/browser/ui/table/plugins/cellSelectionModel.plugin.ts b/src/sql/base/browser/ui/table/plugins/cellSelectionModel.plugin.ts index 831b805404..e000a07491 100644 --- a/src/sql/base/browser/ui/table/plugins/cellSelectionModel.plugin.ts +++ b/src/sql/base/browser/ui/table/plugins/cellSelectionModel.plugin.ts @@ -16,7 +16,7 @@ const defaults: ICellSelectionModelOptions = { }; export class CellSelectionModel implements Slick.SelectionModel> { - private grid: Slick.Grid; + private grid!: Slick.Grid; private selector: ICellRangeSelector; private ranges: Array = []; private _handler = new Slick.EventHandler(); diff --git a/src/sql/base/browser/ui/table/plugins/checkboxSelectColumn.plugin.ts b/src/sql/base/browser/ui/table/plugins/checkboxSelectColumn.plugin.ts index 04b0d482d9..e6bbc10ed3 100644 --- a/src/sql/base/browser/ui/table/plugins/checkboxSelectColumn.plugin.ts +++ b/src/sql/base/browser/ui/table/plugins/checkboxSelectColumn.plugin.ts @@ -47,10 +47,10 @@ const checkboxTemplate = `
; + private _activeOperation?: Thenable; - constructor(private _memento: object) { } + constructor(private _memento: { [key: string]: any }) { } // PUBLIC METHODS ////////////////////////////////////////////////////// public addOrUpdate(newAccount: azdata.Account): Thenable { diff --git a/src/sql/platform/accounts/common/firewallRuleViewModel.ts b/src/sql/platform/accounts/common/firewallRuleViewModel.ts index 68afa61b22..b4161c0e92 100644 --- a/src/sql/platform/accounts/common/firewallRuleViewModel.ts +++ b/src/sql/platform/accounts/common/firewallRuleViewModel.ts @@ -12,33 +12,33 @@ export class FirewallRuleViewModel { public isIPAddressSelected: boolean; public selectedAccount: azdata.Account | undefined; - private _defaultIPAddress: string; - private _defaultFromSubnetIPRange: string; - private _defaultToSubnetIPRange: string; - private _fromSubnetIPRange: string; - private _toSubnetIPRange: string; + private _defaultIPAddress?: string; + private _defaultFromSubnetIPRange?: string; + private _defaultToSubnetIPRange?: string; + private _fromSubnetIPRange?: string; + private _toSubnetIPRange?: string; constructor() { this.isIPAddressSelected = true; } - public get defaultIPAddress(): string { + public get defaultIPAddress(): string | undefined { return this._defaultIPAddress; } - public get defaultFromSubnetIPRange(): string { + public get defaultFromSubnetIPRange(): string | undefined { return this._defaultFromSubnetIPRange; } - public get defaultToSubnetIPRange(): string { + public get defaultToSubnetIPRange(): string | undefined { return this._defaultToSubnetIPRange; } - public set fromSubnetIPRange(IPAddress: string) { + public set fromSubnetIPRange(IPAddress: string | undefined) { this._fromSubnetIPRange = IPAddress; } - public get fromSubnetIPRange(): string { + public get fromSubnetIPRange(): string | undefined { if (this._fromSubnetIPRange) { return this._fromSubnetIPRange; } else { @@ -46,11 +46,11 @@ export class FirewallRuleViewModel { } } - public set toSubnetIPRange(IPAddress: string) { + public set toSubnetIPRange(IPAddress: string | undefined) { this._toSubnetIPRange = IPAddress; } - public get toSubnetIPRange(): string { + public get toSubnetIPRange(): string | undefined { if (this._toSubnetIPRange) { return this._toSubnetIPRange; } else { diff --git a/src/sql/platform/accounts/test/common/accountStore.test.ts b/src/sql/platform/accounts/test/common/accountStore.test.ts index f963ba49b6..1cd6ee9e22 100644 --- a/src/sql/platform/accounts/test/common/accountStore.test.ts +++ b/src/sql/platform/accounts/test/common/accountStore.test.ts @@ -11,7 +11,7 @@ import { EventVerifierSingle } from 'sql/base/test/common/event'; suite('Account Store Tests', () => { test('AddOrUpdate - Uninitialized memento', () => { // Setup: Create account store w/o initialized memento - let memento = {}; + let memento: { [key: string]: azdata.Account[] } = {}; let as = new AccountStore(memento); // If: I add an account to the store @@ -32,7 +32,7 @@ suite('Account Store Tests', () => { test('AddOrUpdate - Adds to accounts', () => { // Setup: Create account store with initialized memento with accounts - let memento = {}; + let memento: { [key: string]: azdata.Account[] } = {}; memento[AccountStore.MEMENTO_KEY] = []; let as = new AccountStore(memento); @@ -99,7 +99,7 @@ suite('Account Store Tests', () => { test('GetAccountsByProvider - No accounts', () => { // Setup: Create account store with initialized memento with accounts - let memento = {}; + let memento: { [key: string]: azdata.Account[] } = {}; memento[AccountStore.MEMENTO_KEY] = []; let as = new AccountStore(memento); @@ -162,7 +162,7 @@ suite('Account Store Tests', () => { test('GetAllAccounts - No accounts', () => { // Setup: Create account store with initialized memento with accounts - let memento = {}; + let memento: { [key: string]: azdata.Account[] } = {}; memento[AccountStore.MEMENTO_KEY] = []; let as = new AccountStore(memento); @@ -193,7 +193,7 @@ suite('Account Store Tests', () => { test('Remove - Uninitialized menento', () => { // Setup: Create account store w/o initialized memento - let memento = {}; + let memento: { [key: string]: azdata.Account[] } = {}; let as = new AccountStore(memento); // If: I remove an account when there's an uninitialized memento @@ -211,7 +211,7 @@ suite('Account Store Tests', () => { test('Remove - Account does not exist', () => { // Setup: Create account store with initialized memento with accounts - let memento = {}; + let memento: { [key: string]: azdata.Account[] } = {}; memento[AccountStore.MEMENTO_KEY] = []; let as = new AccountStore(memento); @@ -250,7 +250,7 @@ suite('Account Store Tests', () => { test('Update - Uninitialized menento', () => { // Setup: // ... Create account store w/o initialized memento - let memento = {}; + let memento: { [key: string]: azdata.Account[] } = {}; let as = new AccountStore(memento); // ... Create a callback that we can verify was called @@ -274,7 +274,7 @@ suite('Account Store Tests', () => { test('Update - Account does not exist', () => { // Setup: Create account store with initialized memento with accounts - let memento = {}; + let memento: { [key: string]: azdata.Account[] } = {}; memento[AccountStore.MEMENTO_KEY] = []; let as = new AccountStore(memento); @@ -358,7 +358,7 @@ const account2 = { }; function getTestMemento() { - let memento = {}; + let memento: { [key: string]: azdata.Account[] } = {}; memento[AccountStore.MEMENTO_KEY] = [account1, account2]; return memento; diff --git a/src/sql/platform/browser/editableDropdown/editableDropdown.component.ts b/src/sql/platform/browser/editableDropdown/editableDropdown.component.ts index cd70c465eb..5ffb999d8d 100644 --- a/src/sql/platform/browser/editableDropdown/editableDropdown.component.ts +++ b/src/sql/platform/browser/editableDropdown/editableDropdown.component.ts @@ -20,15 +20,15 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; template: '' }) export class EditableDropDown extends AngularDisposable implements OnInit, OnChanges { - private _selectbox: Dropdown; + private _selectbox!: Dropdown; - @Input() options: string[]; - @Input() selectedOption: string; + @Input() options!: string[]; + @Input() selectedOption!: string; @Input() onlyEmitOnChange = false; @Output() onDidSelect = new EventEmitter(); - private _previousVal: string; + private _previousVal?: string; constructor( @Inject(forwardRef(() => ElementRef)) private readonly _el: ElementRef, diff --git a/src/sql/platform/browser/inputbox/inputBox.component.ts b/src/sql/platform/browser/inputbox/inputBox.component.ts index 9a269bb5a2..228e8bbbc0 100644 --- a/src/sql/platform/browser/inputbox/inputBox.component.ts +++ b/src/sql/platform/browser/inputbox/inputBox.component.ts @@ -20,14 +20,14 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView template: '' }) export class InputBox extends AngularDisposable implements OnInit, OnChanges { - private _inputbox: vsInputBox; + private _inputbox!: vsInputBox; - @Input() min: string; - @Input() max: string; - @Input() type: string; - @Input() placeholder: string; - @Input('aria-label') ariaLabel: string; - @Input() value: string; + @Input() min?: string; + @Input() max?: string; + @Input() type?: string; + @Input() placeholder?: string; + @Input('aria-label') ariaLabel?: string; + @Input() value?: string; @Output() onDidChange = new EventEmitter(); @@ -67,16 +67,16 @@ export class InputBox extends AngularDisposable implements OnInit, OnChanges { ngOnChanges(changes: SimpleChanges): void { if (this._inputbox) { if (changes['min']) { - this._inputbox.inputElement.min = this.min; + this._inputbox.inputElement.min = this.min!; } if (changes['max']) { - this._inputbox.inputElement.max = this.max; + this._inputbox.inputElement.max = this.max!; } if (changes['type']) { - this._inputbox.inputElement.type = this.type; + this._inputbox.inputElement.type = this.type!; } if (changes['placeholder']) { - this._inputbox.inputElement.placeholder = this.placeholder; + this._inputbox.inputElement.placeholder = this.placeholder!; } } } diff --git a/src/sql/platform/browser/selectBox/selectBox.component.ts b/src/sql/platform/browser/selectBox/selectBox.component.ts index dc3365c417..13720a33da 100644 --- a/src/sql/platform/browser/selectBox/selectBox.component.ts +++ b/src/sql/platform/browser/selectBox/selectBox.component.ts @@ -21,16 +21,16 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; template: '' }) export class SelectBox extends AngularDisposable implements OnInit, OnChanges { - private _selectbox: vsSelectBox; + private _selectbox!: vsSelectBox; - @Input() options: string[]; - @Input() selectedOption: string; + @Input() options!: string[]; + @Input() selectedOption!: string; @Input() onlyEmitOnChange = false; - @Input('aria-label') ariaLabel: string; + @Input('aria-label') ariaLabel?: string; @Output() onDidSelect = new EventEmitter(); - private _previousVal: string; + private _previousVal?: string; constructor( @Inject(forwardRef(() => ElementRef)) private _el: ElementRef, diff --git a/src/sql/platform/connection/common/connectionManagementInfo.ts b/src/sql/platform/connection/common/connectionManagementInfo.ts index 31fa22212d..dd9cb37b84 100644 --- a/src/sql/platform/connection/common/connectionManagementInfo.ts +++ b/src/sql/platform/connection/common/connectionManagementInfo.ts @@ -10,62 +10,56 @@ import { StopWatch } from 'vs/base/common/stopwatch'; /** * Information for a document's connection. Exported for testing purposes. */ -export class ConnectionManagementInfo { +export interface ConnectionManagementInfo { /** * Connection GUID returned from the service host */ - public connectionId: string; + connectionId?: string; - - public providerId: string; + providerId: string; /** * Credentials used to connect */ - public connectionProfile: ConnectionProfile; + connectionProfile: ConnectionProfile; /** * Callback for when a connection notification is received. */ - public connectHandler: (result: boolean, errorMessage?: string, errorCode?: number, callStack?: string) => void; - - /** - * Information about the SQL Server instance. - */ - //public serverInfo: ConnectionContracts.ServerInfo; + connectHandler?: (result: boolean, errorMessage?: string, errorCode?: number, callStack?: string) => void; /** * Timer for tracking extension connection time. */ - public extensionTimer: StopWatch; + extensionTimer: StopWatch; /** * Timer for tracking service connection time. */ - public serviceTimer: StopWatch; + serviceTimer: StopWatch; /** * Timer for tracking intelliSense activation time. */ - public intelliSenseTimer: StopWatch; + intelliSenseTimer: StopWatch; /** * Whether the connection is in the process of connecting. */ - public connecting: boolean; + connecting: boolean; /** * Whether the connection should be deleted after connection is complete. */ - public deleted: boolean; + deleted?: boolean; /** * Information about the connected server. */ - serverInfo: azdata.ServerInfo; + serverInfo?: azdata.ServerInfo; /** * Owner uri assigned to the connection */ - public ownerUri: string; + ownerUri: string; } diff --git a/src/sql/platform/connection/common/connectionProfile.ts b/src/sql/platform/connection/common/connectionProfile.ts index 6e49c27f63..bb5a5267ed 100644 --- a/src/sql/platform/connection/common/connectionProfile.ts +++ b/src/sql/platform/connection/common/connectionProfile.ts @@ -27,7 +27,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa private _id: string; public savePassword: boolean; private _groupName?: string; - public groupId: string; + public groupId?: string; public saveProfile: boolean; public isDisconnecting: boolean = false; @@ -256,7 +256,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa let connectionInfo = ConnectionProfile.fromIConnectionProfile(capabilitiesService, connectionProfile); let profile: interfaces.IConnectionProfileStore = { options: {}, - groupId: connectionProfile.groupId, + groupId: connectionProfile.groupId!, providerName: connectionInfo.providerName, savePassword: connectionInfo.savePassword, id: connectionInfo.id diff --git a/src/sql/platform/connection/common/connectionProfileGroup.ts b/src/sql/platform/connection/common/connectionProfileGroup.ts index 26994678d7..d010a64383 100644 --- a/src/sql/platform/connection/common/connectionProfileGroup.ts +++ b/src/sql/platform/connection/common/connectionProfileGroup.ts @@ -19,10 +19,10 @@ export interface IConnectionProfileGroup { export class ConnectionProfileGroup extends Disposable implements IConnectionProfileGroup { - public children: ConnectionProfileGroup[]; - public connections: ConnectionProfile[]; + public children: ConnectionProfileGroup[] = []; + public connections: ConnectionProfile[] = []; public parentId?: string; - private _isRenamed: boolean; + private _isRenamed = false; public constructor( public name: string, public parent: ConnectionProfileGroup | undefined, @@ -42,7 +42,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro public toObject(): IConnectionProfileGroup { let subgroups = undefined; - if (this.children) { + if (this.children.length > 0) { subgroups = []; this.children.forEach((group) => { subgroups.push(group.toObject()); @@ -129,9 +129,6 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro } public addConnections(connections: ConnectionProfile[]): void { - if (!this.connections) { - this.connections = []; - } connections.forEach((conn) => { this.connections = this.connections.filter((curConn) => { return curConn.id !== conn.id; }); conn.parent = this; @@ -142,9 +139,6 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro } public addGroups(groups: ConnectionProfileGroup[]): void { - if (!this.children) { - this.children = []; - } groups.forEach((group) => { this.children = this.children.filter((grp) => { return group.id !== grp.id; }); group.parent = this; diff --git a/src/sql/platform/connection/common/connectionStatusManager.ts b/src/sql/platform/connection/common/connectionStatusManager.ts index 59231c12ed..7574549cc3 100644 --- a/src/sql/platform/connection/common/connectionStatusManager.ts +++ b/src/sql/platform/connection/common/connectionStatusManager.ts @@ -77,15 +77,16 @@ export class ConnectionStatusManager { this._logService.info(`Adding connection ${id}`); // Always create a copy and save that in the list let connectionProfile = new ConnectionProfile(this._capabilitiesService, connection); - let connectionInfo: ConnectionManagementInfo = new ConnectionManagementInfo(); - connectionInfo.providerId = connection.providerName; - connectionInfo.extensionTimer = StopWatch.create(); - connectionInfo.intelliSenseTimer = StopWatch.create(); - connectionInfo.connectionProfile = connectionProfile; - connectionInfo.connecting = true; + let connectionInfo: ConnectionManagementInfo = { + providerId: connection.providerName, + extensionTimer: StopWatch.create(), + intelliSenseTimer: StopWatch.create(), + connectionProfile: connectionProfile, + connecting: true, + serviceTimer: StopWatch.create(), + ownerUri: id + }; this._connections[id] = connectionInfo; - connectionInfo.serviceTimer = StopWatch.create(); - connectionInfo.ownerUri = id; this._logService.info(`Successfully added connection ${id}`); return connectionInfo; } diff --git a/src/sql/platform/connection/common/interfaces.ts b/src/sql/platform/connection/common/interfaces.ts index 8378aa1f27..2abab53d56 100644 --- a/src/sql/platform/connection/common/interfaces.ts +++ b/src/sql/platform/connection/common/interfaces.ts @@ -11,7 +11,7 @@ export interface IConnectionProfile extends azdata.IConnectionProfile { } export interface IConnectionProfileStore { - options: {}; + options: { [key: string]: any }; groupId: string; providerName: string; savePassword: boolean; diff --git a/src/sql/platform/connection/common/providerConnectionInfo.ts b/src/sql/platform/connection/common/providerConnectionInfo.ts index 8d6ac9e1b0..2f9eeedda4 100644 --- a/src/sql/platform/connection/common/providerConnectionInfo.ts +++ b/src/sql/platform/connection/common/providerConnectionInfo.ts @@ -19,9 +19,9 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect options: { [name: string]: any } = {}; - private _providerName: string; - private _onCapabilitiesRegisteredDisposable: IDisposable; - protected _serverCapabilities: ConnectionProviderProperties; + private _providerName?: string; + private _onCapabilitiesRegisteredDisposable?: IDisposable; + protected _serverCapabilities?: ConnectionProviderProperties; private static readonly SqlAuthentication = 'SqlLogin'; public static readonly ProviderPropertyName = 'providerName'; @@ -66,7 +66,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect } public get providerName(): string { - return this._providerName; + return this._providerName!; // this needs to be rewritten at some point } public set providerName(name: string) { @@ -100,7 +100,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect return instance; } - public get serverCapabilities(): ConnectionProviderProperties { + public get serverCapabilities(): ConnectionProviderProperties | undefined { return this._serverCapabilities; } @@ -189,7 +189,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect * Returns true if the capabilities and options are loaded correctly */ public get isConnectionOptionsValid(): boolean { - return this.serverCapabilities && this.title.indexOf('undefined') < 0; + return !!this.serverCapabilities && this.title.indexOf('undefined') < 0; } public isPasswordRequired(): boolean { @@ -284,7 +284,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect } public get authenticationTypeDisplayName(): string { - let optionMetadata = find(this._serverCapabilities.connectionOptions, o => o.specialValueType === ConnectionOptionSpecialType.authType); + let optionMetadata = this._serverCapabilities ? find(this._serverCapabilities.connectionOptions, o => o.specialValueType === ConnectionOptionSpecialType.authType) : undefined; let authType = this.authenticationType; let displayName: string = authType; @@ -298,8 +298,8 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect return displayName; } - public getProviderOptions(): azdata.ConnectionOption[] { - return this._serverCapabilities.connectionOptions; + public getProviderOptions(): azdata.ConnectionOption[] | undefined { + return this._serverCapabilities?.connectionOptions; } public static get idSeparator(): string { @@ -317,19 +317,21 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect parts.push(this.databaseName); parts.push(this.authenticationTypeDisplayName); - this._serverCapabilities.connectionOptions.forEach(element => { - if (element.specialValueType !== ConnectionOptionSpecialType.serverName && - element.specialValueType !== ConnectionOptionSpecialType.databaseName && - element.specialValueType !== ConnectionOptionSpecialType.authType && - element.specialValueType !== ConnectionOptionSpecialType.password && - element.specialValueType !== ConnectionOptionSpecialType.connectionName && - element.isIdentity && element.valueType === ServiceOptionType.string) { - let value = this.getOptionValue(element.name); - if (value) { - parts.push(value); + if (this._serverCapabilities) { + this._serverCapabilities.connectionOptions.forEach(element => { + if (element.specialValueType !== ConnectionOptionSpecialType.serverName && + element.specialValueType !== ConnectionOptionSpecialType.databaseName && + element.specialValueType !== ConnectionOptionSpecialType.authType && + element.specialValueType !== ConnectionOptionSpecialType.password && + element.specialValueType !== ConnectionOptionSpecialType.connectionName && + element.isIdentity && element.valueType === ServiceOptionType.string) { + let value = this.getOptionValue(element.name); + if (value) { + parts.push(value); + } } - } - }); + }); + } return parts; } diff --git a/src/sql/platform/connection/test/common/connectionConfig.test.ts b/src/sql/platform/connection/test/common/connectionConfig.test.ts index d8c4e46a2f..15377620b9 100644 --- a/src/sql/platform/connection/test/common/connectionConfig.test.ts +++ b/src/sql/platform/connection/test/common/connectionConfig.test.ts @@ -126,11 +126,11 @@ suite('ConnectionConfig', () => { options: [ { name: 'serverName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.serverName, @@ -138,11 +138,11 @@ suite('ConnectionConfig', () => { }, { name: 'databaseName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.databaseName, @@ -150,11 +150,11 @@ suite('ConnectionConfig', () => { }, { name: 'userName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.userName, @@ -162,11 +162,11 @@ suite('ConnectionConfig', () => { }, { name: 'authenticationType', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.authType, @@ -174,11 +174,11 @@ suite('ConnectionConfig', () => { }, { name: 'password', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.password, @@ -218,7 +218,7 @@ suite('ConnectionConfig', () => { } // weird way to verify that each group appears the same number of times in each array - let result = groupsAreEqual(groups1.filter(a => a.parentId === group.id), groups2.filter(b => b.parentId === g2.id)); + let result = groupsAreEqual(groups1.filter(a => a.parentId === group.id), groups2.filter(b => b.parentId === g2!.id)); if (!result) { return false; } @@ -251,13 +251,13 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: undefined, groupId: undefined, - getOptionsKey: undefined, - matches: undefined, + getOptionsKey: undefined!, + matches: undefined!, providerName: 'MSSQL', options: {}, saveProfile: true, - id: undefined, - connectionName: undefined + id: undefined!, + connectionName: undefined! }; let configurationService = new TestConfigurationService(); @@ -269,7 +269,7 @@ suite('ConnectionConfig', () => { let savedConnectionProfile = await config.addConnection(connectionProfile); assert.ok(!!savedConnectionProfile.id); - assert.equal(configurationService.inspect('datasource.connections').userValue.length, testConnections.length + 1); + assert.equal(configurationService.inspect('datasource.connections').userValue!.length, testConnections.length + 1); }); test('addConnection should not add the new profile to user settings if already exists', async () => { @@ -283,13 +283,13 @@ suite('ConnectionConfig', () => { groupId: existingConnection.groupId, savePassword: true, groupFullName: undefined, - getOptionsKey: undefined, - matches: undefined, + getOptionsKey: undefined!, + matches: undefined!, providerName: 'MSSQL', options: {}, saveProfile: true, - id: undefined, - connectionName: undefined + id: undefined!, + connectionName: undefined! }; let configurationService = new TestConfigurationService(); @@ -303,7 +303,7 @@ suite('ConnectionConfig', () => { let savedConnectionProfile = await config.addConnection(connectionProfile); assert.equal(savedConnectionProfile.id, existingConnection.id); - assert.equal(configurationService.inspect('datasource.connections').userValue.length, testConnections.length); + assert.equal(configurationService.inspect('datasource.connections').userValue!.length, testConnections.length); }); test('addConnection should add the new group to user settings if does not exist', async () => { @@ -316,13 +316,13 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'g2/g2-2', groupId: undefined, - getOptionsKey: undefined, - matches: undefined, + getOptionsKey: undefined!, + matches: undefined!, providerName: 'MSSQL', options: {}, saveProfile: true, - id: undefined, - connectionName: undefined + id: undefined!, + connectionName: undefined! }; let configurationService = new TestConfigurationService(); @@ -333,8 +333,8 @@ suite('ConnectionConfig', () => { let config = new ConnectionConfig(configurationService, capabilitiesService.object); await config.addConnection(connectionProfile); - assert.equal(configurationService.inspect('datasource.connections').userValue.length, testConnections.length + 1); - assert.equal(configurationService.inspect('datasource.connectionGroups').userValue.length, testGroups.length + 1); + assert.equal(configurationService.inspect('datasource.connections').userValue!.length, testConnections.length + 1); + assert.equal(configurationService.inspect('datasource.connectionGroups').userValue!.length, testGroups.length + 1); }); test('getConnections should return connections from user and workspace settings given getWorkspaceConnections set to true', () => { @@ -363,7 +363,7 @@ suite('ConnectionConfig', () => { return c; }); let userConnections = deepClone(testConnections).map(c => { - c.id = undefined; + c.id = undefined!; return c; }); let configurationService = new TestConfigurationService(); @@ -381,13 +381,13 @@ suite('ConnectionConfig', () => { } else { let workspaceConnection = find(workspaceConnections, u => u.options['serverName'] === connection.serverName); assert.notEqual(connection.id, connection.getOptionsKey()); - assert.equal(workspaceConnection.id, connection.id); + assert.equal(workspaceConnection!.id, connection.id); } }); }); test('saveGroup should save the new groups to tree and return the id of the last group name', () => { - let config = new ConnectionConfig(undefined, undefined); + let config = new ConnectionConfig(undefined!, undefined!); let groups: IConnectionProfileGroup[] = deepClone(testGroups); let newGroups: string = 'ROOT/g1/g1-1/new-group/new-group2'; let color: string = 'red'; @@ -396,11 +396,11 @@ suite('ConnectionConfig', () => { assert.ok(!!result); assert.equal(result.groups.length, testGroups.length + 2, 'The result groups length is invalid'); let newGroup = find(result.groups, g => g.name === 'new-group2'); - assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid'); + assert.equal(result.newGroupId, newGroup!.id, 'The groups id is invalid'); }); test('saveGroup should only add the groups that are not in the tree', () => { - let config = new ConnectionConfig(undefined, undefined); + let config = new ConnectionConfig(undefined!, undefined!); let groups: IConnectionProfileGroup[] = deepClone(testGroups); let newGroups: string = 'ROOT/g2/g2-5'; let color: string = 'red'; @@ -409,11 +409,11 @@ suite('ConnectionConfig', () => { assert.ok(!!result); assert.equal(result.groups.length, testGroups.length + 1, 'The result groups length is invalid'); let newGroup = find(result.groups, g => g.name === 'g2-5'); - assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid'); + assert.equal(result.newGroupId, newGroup!.id, 'The groups id is invalid'); }); test('saveGroup should not add any new group if tree already has all the groups in the full path', () => { - let config = new ConnectionConfig(undefined, undefined); + let config = new ConnectionConfig(undefined!, undefined!); let groups: IConnectionProfileGroup[] = deepClone(testGroups); let newGroups: string = 'ROOT/g2/g2-1'; let color: string = 'red'; @@ -422,7 +422,7 @@ suite('ConnectionConfig', () => { assert.ok(!!result); assert.equal(result.groups.length, testGroups.length, 'The result groups length is invalid'); let newGroup = find(result.groups, g => g.name === 'g2-1'); - assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid'); + assert.equal(result.newGroupId, newGroup!.id, 'The groups id is invalid'); }); test('deleteConnection should remove the connection from config', async () => { @@ -435,13 +435,13 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'g3', groupId: 'g3', - getOptionsKey: undefined, - matches: undefined, + getOptionsKey: undefined!, + matches: undefined!, providerName: 'MSSQL', options: {}, saveProfile: true, - id: undefined, - connectionName: undefined + id: undefined!, + connectionName: undefined! }; let configurationService = new TestConfigurationService(); configurationService.updateValue('datasource.connections', deepClone(testConnections), ConfigurationTarget.USER); @@ -452,7 +452,7 @@ suite('ConnectionConfig', () => { let config = new ConnectionConfig(configurationService, capabilitiesService.object); await config.deleteConnection(connectionProfile); - assert.equal(configurationService.inspect('datasource.connections').userValue.length, testConnections.length - 1); + assert.equal(configurationService.inspect('datasource.connections').userValue!.length, testConnections.length - 1); }); test('deleteConnectionGroup should remove the children connections and subgroups from config', async () => { @@ -465,13 +465,13 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'g3', groupId: 'g3', - getOptionsKey: undefined, - matches: undefined, + getOptionsKey: undefined!, + matches: undefined!, providerName: 'MSSQL', options: {}, saveProfile: true, - id: undefined, - connectionName: undefined + id: undefined!, + connectionName: undefined! }; let configurationService = new TestConfigurationService(); configurationService.updateValue('datasource.connections', deepClone(testConnections), ConfigurationTarget.USER); @@ -488,8 +488,8 @@ suite('ConnectionConfig', () => { let config = new ConnectionConfig(configurationService, capabilitiesService.object); await config.deleteGroup(connectionProfileGroup); - assert.equal(configurationService.inspect('datasource.connections').userValue.length, testConnections.length - 1); - assert.equal(configurationService.inspect('datasource.connectionGroups').userValue.length, testGroups.length - 2); + assert.equal(configurationService.inspect('datasource.connections').userValue!.length, testConnections.length - 1); + assert.equal(configurationService.inspect('datasource.connectionGroups').userValue!.length, testGroups.length - 2); }); test('deleteConnection should not throw error for connection not in config', async () => { @@ -502,13 +502,13 @@ suite('ConnectionConfig', () => { savePassword: true, groupFullName: 'g3', groupId: 'newid', - getOptionsKey: undefined, - matches: undefined, + getOptionsKey: undefined!, + matches: undefined!, providerName: 'MSSQL', options: {}, saveProfile: true, - id: undefined, - connectionName: undefined + id: undefined!, + connectionName: undefined! }; let configurationService = new TestConfigurationService(); configurationService.updateValue('datasource.connections', deepClone(testConnections), ConfigurationTarget.USER); @@ -517,7 +517,7 @@ suite('ConnectionConfig', () => { let config = new ConnectionConfig(configurationService, capabilitiesService.object); await config.deleteConnection(connectionProfile); - assert.equal(configurationService.inspect('datasource.connections').userValue.length, testConnections.length); + assert.equal(configurationService.inspect('datasource.connections').userValue!.length, testConnections.length); }); test('renameGroup should change group name', async () => { @@ -528,12 +528,12 @@ suite('ConnectionConfig', () => { let config = new ConnectionConfig(configurationService, capabilitiesService.object); await config.editGroup(connectionProfileGroup); - let editedGroups = configurationService.inspect('datasource.connectionGroups').userValue; + let editedGroups = configurationService.inspect('datasource.connectionGroups').userValue!; assert.equal(editedGroups.length, testGroups.length); let editedGroup = find(editedGroups, group => group.id === 'g2'); assert.ok(!!editedGroup); - assert.equal(editedGroup.name, 'g-renamed'); + assert.equal(editedGroup!.name, 'g-renamed'); }); test('edit group should throw if there is a confliction', async () => { @@ -547,10 +547,10 @@ suite('ConnectionConfig', () => { await config.editGroup(sameNameGroup); assert.fail(); } catch (e) { - let groups = configurationService.inspect('datasource.connectionGroups').userValue; + let groups = configurationService.inspect('datasource.connectionGroups').userValue!; let originalGroup = find(groups, g => g.id === 'g2'); assert.ok(!!originalGroup); - assert.equal(originalGroup.name, 'g2'); + assert.equal(originalGroup!.name, 'g2'); } }); @@ -563,12 +563,12 @@ suite('ConnectionConfig', () => { let config = new ConnectionConfig(configurationService, capabilitiesService.object); await config.changeGroupIdForConnectionGroup(sourceProfileGroup, targetProfileGroup); - let editedGroups = configurationService.inspect('datasource.connectionGroups').userValue; + let editedGroups = configurationService.inspect('datasource.connectionGroups').userValue!; assert.equal(editedGroups.length, testGroups.length); let editedGroup = find(editedGroups, group => group.id === 'g2'); assert.ok(!!editedGroup); - assert.equal(editedGroup.parentId, 'g3'); + assert.equal(editedGroup!.parentId, 'g3'); }); @@ -583,12 +583,12 @@ suite('ConnectionConfig', () => { groupFullName: 'g3', groupId: 'g3', getOptionsKey: () => { return 'connectionId'; }, - matches: undefined, + matches: undefined!, providerName: 'MSSQL', options: {}, saveProfile: true, id: 'server3-2', - connectionName: undefined + connectionName: undefined! }; let existingProfile = ConnectionProfile.convertToProfileStore(capabilitiesService.object, { serverName: 'server3', @@ -600,15 +600,15 @@ suite('ConnectionConfig', () => { groupFullName: 'test', groupId: 'test', getOptionsKey: () => { return 'connectionId'; }, - matches: undefined, + matches: undefined!, providerName: 'MSSQL', options: {}, saveProfile: true, id: 'server3', - connectionName: undefined + connectionName: undefined! }); - let _testConnections = deepClone(testConnections).concat([existingProfile, changingProfile]); + let _testConnections = [...deepClone(testConnections), existingProfile, changingProfile]; let configurationService = new TestConfigurationService(); configurationService.updateValue('datasource.connections', _testConnections, ConfigurationTarget.USER); @@ -620,12 +620,12 @@ suite('ConnectionConfig', () => { await config.changeGroupIdForConnection(connectionProfile, 'test'); assert.fail(); } catch (e) { - let editedConnections = configurationService.inspect('datasource.connections').userValue; + let editedConnections = configurationService.inspect('datasource.connections').userValue!; // two assert.equal(editedConnections.length, _testConnections.length); let editedConnection = find(editedConnections, con => con.id === 'server3-2'); assert.ok(!!editedConnection); - assert.equal(editedConnection.groupId, 'g3'); + assert.equal(editedConnection!.groupId, 'g3'); } }); @@ -640,12 +640,12 @@ suite('ConnectionConfig', () => { groupFullName: 'g3', groupId: 'g3', getOptionsKey: () => { return 'connectionId'; }, - matches: undefined, + matches: undefined!, providerName: 'MSSQL', options: {}, saveProfile: true, id: 'server3', - connectionName: undefined + connectionName: undefined! }; let configurationService = new TestConfigurationService(); @@ -657,11 +657,11 @@ suite('ConnectionConfig', () => { let config = new ConnectionConfig(configurationService, capabilitiesService.object); await config.changeGroupIdForConnection(connectionProfile, newId); - let editedConnections = configurationService.inspect('datasource.connections').userValue; + let editedConnections = configurationService.inspect('datasource.connections').userValue!; assert.equal(editedConnections.length, testConnections.length); let editedConnection = find(editedConnections, con => con.id === 'server3'); assert.ok(!!editedConnection); - assert.equal(editedConnection.groupId, 'newid'); + assert.equal(editedConnection!.groupId, 'newid'); }); test('addConnection should not move the connection when editing', async () => { @@ -691,7 +691,7 @@ suite('ConnectionConfig', () => { test('addgroup works', async () => { let newGroup: IConnectionProfileGroup = { - id: undefined, + id: undefined!, parentId: undefined, name: 'new group', color: 'red', @@ -704,14 +704,14 @@ suite('ConnectionConfig', () => { await config.addGroup(newGroup); - let editGroups = configurationService.inspect('datasource.connectionGroups').userValue; + let editGroups = configurationService.inspect('datasource.connectionGroups').userValue!; assert.equal(editGroups.length, testGroups.length + 1); }); test('addGroup rejects if group name already exists', async () => { let existingGroupName: IConnectionProfileGroup = { - id: undefined, + id: undefined!, parentId: undefined, name: 'g2', color: 'red', @@ -725,7 +725,7 @@ suite('ConnectionConfig', () => { await config.addGroup(existingGroupName); assert.fail(); } catch (e) { - let editGroups = configurationService.inspect('datasource.connectionGroups').userValue; + let editGroups = configurationService.inspect('datasource.connectionGroups').userValue!; assert.equal(editGroups.length, testGroups.length); } diff --git a/src/sql/platform/connection/test/common/connectionProfile.test.ts b/src/sql/platform/connection/test/common/connectionProfile.test.ts index d9544d64e0..9bbb5a2d50 100644 --- a/src/sql/platform/connection/test/common/connectionProfile.test.ts +++ b/src/sql/platform/connection/test/common/connectionProfile.test.ts @@ -27,12 +27,12 @@ suite('SQL ConnectionProfileInfo tests', () => { savePassword: true, groupFullName: 'g2/g2-2', groupId: 'group id', - getOptionsKey: undefined, - matches: undefined, + getOptionsKey: undefined!, + matches: undefined!, providerName: mssqlProviderName, options: {}, saveProfile: true, - id: undefined + id: undefined! }; let storedProfile: IConnectionProfileStore = { @@ -54,11 +54,11 @@ suite('SQL ConnectionProfileInfo tests', () => { let connectionProvider: azdata.ConnectionOption[] = [ { name: 'connectionName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.connectionName, @@ -66,11 +66,11 @@ suite('SQL ConnectionProfileInfo tests', () => { }, { name: 'serverName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.serverName, @@ -78,11 +78,11 @@ suite('SQL ConnectionProfileInfo tests', () => { }, { name: 'databaseName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.databaseName, @@ -90,11 +90,11 @@ suite('SQL ConnectionProfileInfo tests', () => { }, { name: 'userName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.userName, @@ -102,11 +102,11 @@ suite('SQL ConnectionProfileInfo tests', () => { }, { name: 'authenticationType', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.authType, @@ -114,11 +114,11 @@ suite('SQL ConnectionProfileInfo tests', () => { }, { name: 'password', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.password, @@ -135,7 +135,7 @@ suite('SQL ConnectionProfileInfo tests', () => { }); test('set properties should set the values correctly', () => { - let conn = new ConnectionProfile(capabilitiesService, undefined); + let conn = new ConnectionProfile(capabilitiesService, undefined!); assert.equal(conn.serverName, undefined); conn.connectionName = connectionProfile.connectionName; conn.serverName = connectionProfile.serverName; diff --git a/src/sql/platform/connection/test/common/connectionProfileGroup.test.ts b/src/sql/platform/connection/test/common/connectionProfileGroup.test.ts index b04a022992..e46deb6f24 100644 --- a/src/sql/platform/connection/test/common/connectionProfileGroup.test.ts +++ b/src/sql/platform/connection/test/common/connectionProfileGroup.test.ts @@ -43,7 +43,7 @@ suite('SQL ConnectionProfileGroup tests', () => { }); test('getGroupFullNameParts should return a list With ROOT in it given null', () => { - let groupFullName: string = undefined; + let groupFullName: string = undefined!; let expected: string[] = [ConnectionProfileGroup.RootGroupName]; let actual = ConnectionProfileGroup.getGroupFullNameParts(groupFullName); assert.deepEqual(actual, expected); @@ -99,7 +99,7 @@ suite('SQL ConnectionProfileGroup tests', () => { }); test('isRoot should return true given null', () => { - let name: string = undefined; + let name: string = undefined!; let expected: boolean = true; let actual = ConnectionProfileGroup.isRoot(name); assert.deepEqual(actual, expected); diff --git a/src/sql/platform/connection/test/common/connectionStore.test.ts b/src/sql/platform/connection/test/common/connectionStore.test.ts index 74a35d8a5b..fa88182ad4 100644 --- a/src/sql/platform/connection/test/common/connectionStore.test.ts +++ b/src/sql/platform/connection/test/common/connectionStore.test.ts @@ -31,12 +31,12 @@ suite('ConnectionStore', () => { savePassword: true, groupId: '', groupFullName: '', - getOptionsKey: undefined, + getOptionsKey: undefined!, matches: () => false, providerName: mssqlProviderName, options: {}, saveProfile: true, - id: undefined + id: undefined! }); let capabilitiesService: TestCapabilitiesService; let maxRecent = 5; @@ -51,11 +51,11 @@ suite('ConnectionStore', () => { let connectionProvider: azdata.ConnectionOption[] = [ { name: 'connectionName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.connectionName, @@ -63,11 +63,11 @@ suite('ConnectionStore', () => { }, { name: 'serverName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.serverName, @@ -75,11 +75,11 @@ suite('ConnectionStore', () => { }, { name: 'databaseName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.databaseName, @@ -87,11 +87,11 @@ suite('ConnectionStore', () => { }, { name: 'userName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.userName, @@ -99,11 +99,11 @@ suite('ConnectionStore', () => { }, { name: 'authenticationType', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.authType, @@ -111,11 +111,11 @@ suite('ConnectionStore', () => { }, { name: 'password', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.password, @@ -232,8 +232,8 @@ suite('ConnectionStore', () => { let current = connectionStore.getRecentlyUsedConnections(); // Then verify that since its password based we save the password assert.equal(credentialsService.credentials.size, 1); - assert.strictEqual(recentCredential.password, defaultNamedProfile.password); - assert.ok(recentCredential.credentialId.indexOf('Profile') > -1, 'Expect credential to be marked as an Profile cred'); + assert.strictEqual(recentCredential!.password, defaultNamedProfile.password); + assert.ok(recentCredential!.credentialId.indexOf('Profile') > -1, 'Expect credential to be marked as an Profile cred'); assert.ok(!current[0].password); // When add integrated auth connection const integratedCredConnectionProfile = new ConnectionProfile(capabilitiesService, integratedCred); @@ -376,11 +376,11 @@ suite('ConnectionStore', () => { credentialsService, capabilitiesService); // If I look up the parent group using its ID, then I get back the correct group - let actualGroup = connectionStore.getGroupFromId(parentGroupId); + let actualGroup = connectionStore.getGroupFromId(parentGroupId)!; assert.equal(actualGroup.id, parentGroupId, 'Did not get the parent group when looking it up with its ID'); // If I look up the child group using its ID, then I get back the correct group - actualGroup = connectionStore.getGroupFromId(childGroupId); + actualGroup = connectionStore.getGroupFromId(childGroupId)!; assert.equal(actualGroup.id, childGroupId, 'Did not get the child group when looking it up with its ID'); }); diff --git a/src/sql/platform/connection/test/common/providerConnectionInfo.test.ts b/src/sql/platform/connection/test/common/providerConnectionInfo.test.ts index 205ad419bd..1e31b04406 100644 --- a/src/sql/platform/connection/test/common/providerConnectionInfo.test.ts +++ b/src/sql/platform/connection/test/common/providerConnectionInfo.test.ts @@ -26,12 +26,12 @@ suite('SQL ProviderConnectionInfo tests', () => { savePassword: true, groupFullName: 'g2/g2-2', groupId: undefined, - getOptionsKey: undefined, - matches: undefined, + getOptionsKey: undefined!, + matches: undefined!, providerName: mssqlProviderName, - options: undefined, + options: undefined!, saveProfile: true, - id: undefined + id: undefined! }; setup(() => { @@ -39,11 +39,11 @@ suite('SQL ProviderConnectionInfo tests', () => { let connectionProvider: azdata.ConnectionOption[] = [ { name: 'connectionName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.connectionName, @@ -51,11 +51,11 @@ suite('SQL ProviderConnectionInfo tests', () => { }, { name: 'serverName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.serverName, @@ -63,11 +63,11 @@ suite('SQL ProviderConnectionInfo tests', () => { }, { name: 'databaseName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.databaseName, @@ -75,11 +75,11 @@ suite('SQL ProviderConnectionInfo tests', () => { }, { name: 'userName', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.userName, @@ -87,11 +87,11 @@ suite('SQL ProviderConnectionInfo tests', () => { }, { name: 'authenticationType', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.authType, @@ -99,11 +99,11 @@ suite('SQL ProviderConnectionInfo tests', () => { }, { name: 'password', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: true, isRequired: true, specialValueType: ConnectionOptionSpecialType.password, @@ -111,14 +111,14 @@ suite('SQL ProviderConnectionInfo tests', () => { }, { name: 'encrypt', - displayName: undefined, - description: undefined, - groupName: undefined, - categoryValues: undefined, - defaultValue: undefined, + displayName: undefined!, + description: undefined!, + groupName: undefined!, + categoryValues: undefined!, + defaultValue: undefined!, isIdentity: false, isRequired: false, - specialValueType: undefined, + specialValueType: undefined!, valueType: ServiceOptionType.string } ]; @@ -133,7 +133,7 @@ suite('SQL ProviderConnectionInfo tests', () => { }); test('constructor should accept undefined parameters', () => { - let conn = new ProviderConnectionInfo(undefined, undefined); + let conn = new ProviderConnectionInfo(undefined!, undefined!); assert.equal(conn.serverName, undefined); }); @@ -201,7 +201,7 @@ suite('SQL ProviderConnectionInfo tests', () => { }); test('constructor should initialize the options given a valid model with options', () => { - let options = {}; + let options: { [key: string]: string } = {}; options['encrypt'] = 'test value'; let conn2 = assign({}, connectionProfile, { options: options }); let conn = new ProviderConnectionInfo(capabilitiesService, conn2); @@ -247,7 +247,7 @@ suite('SQL ProviderConnectionInfo tests', () => { }); test('getProviderFromOptionsKey should return empty string give null', () => { - let optionsKey = undefined; + let optionsKey = undefined!; let expectedProviderId: string = ''; let actual = ProviderConnectionInfo.getProviderFromOptionsKey(optionsKey); diff --git a/src/sql/platform/connection/test/common/testConfigurationService.ts b/src/sql/platform/connection/test/common/testConfigurationService.ts index c3ce93d1fb..b1051504fb 100644 --- a/src/sql/platform/connection/test/common/testConfigurationService.ts +++ b/src/sql/platform/connection/test/common/testConfigurationService.ts @@ -8,7 +8,7 @@ import { getConfigurationKeys, IConfigurationOverrides, IConfigurationService, g export class TestConfigurationService implements IConfigurationService { public _serviceBrand: undefined; - private configuration = { + private configuration: { user: { [key: string]: any }; workspace: { [key: string]: any } } = { user: {}, workspace: {} }; @@ -22,7 +22,7 @@ export class TestConfigurationService implements IConfigurationService { } public updateValue(key: string, value: any, target?: any): Promise { - let _target = (target as ConfigurationTarget) === ConfigurationTarget.USER ? 'user' : 'workspace'; + let _target: 'user' | 'workspace' = (target as ConfigurationTarget) === ConfigurationTarget.USER ? 'user' : 'workspace'; let keyArray = key.split('.'); let targetObject = this.configuration[_target]; for (let i = 0; i < keyArray.length; i++) { diff --git a/src/sql/platform/connection/test/common/testConnectionManagementService.ts b/src/sql/platform/connection/test/common/testConnectionManagementService.ts index 590340ac14..5a3a9187a4 100644 --- a/src/sql/platform/connection/test/common/testConnectionManagementService.ts +++ b/src/sql/platform/connection/test/common/testConnectionManagementService.ts @@ -16,11 +16,16 @@ import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/c // Test stubs for commonly used objects export class TestConnectionManagementService implements IConnectionManagementService { + disconnect(connection: IConnectionProfile): Promise; + disconnect(ownerUri: string): Promise; + disconnect(ownerUri: any) { + return Promise.resolve(); + } _serviceBrand: undefined; - onAddConnectionProfile = undefined; - onDeleteConnectionProfile = undefined; - onConnectionChanged = undefined; - onLanguageFlavorChanged = undefined; + onAddConnectionProfile = undefined!; + onDeleteConnectionProfile = undefined!; + onConnectionChanged = undefined!; + onLanguageFlavorChanged = undefined!; public get onConnect(): Event { return Event.None; @@ -43,15 +48,15 @@ export class TestConnectionManagementService implements IConnectionManagementSer } showConnectionDialog(params?: INewConnectionParams, options?: IConnectionCompletionOptions, model?: IConnectionProfile, connectionResult?: IConnectionResult): Promise { - return undefined; + return undefined!; } showCreateServerGroupDialog(): Promise { - return undefined; + return undefined!; } showEditServerGroupDialog(group: ConnectionProfileGroup): Promise { - return undefined; + return undefined!; } onConnectionComplete(handle: number, connectionInfoSummary: azdata.ConnectionInfoSummary): void { @@ -67,7 +72,7 @@ export class TestConnectionManagementService implements IConnectionManagementSer } getCurrentConnectionSummary(): azdata.ConnectionSummary { - return undefined; + return undefined!; } getConnectionGroups(providers?: string[]): ConnectionProfileGroup[] { @@ -79,7 +84,7 @@ export class TestConnectionManagementService implements IConnectionManagementSer } saveProfileGroup(profile: IConnectionProfileGroup): Promise { - return undefined; + return undefined!; } getRecentConnections(providers?: string[]): ConnectionProfile[] { @@ -123,15 +128,15 @@ export class TestConnectionManagementService implements IConnectionManagementSer } getConnectionUri(connectionProfile: ConnectionProfile): string { - return undefined; + return undefined!; } getFormattedUri(uri: string, connectionProfile: ConnectionProfile): string { - return undefined; + return undefined!; } getConnectionUriFromId(connectionId: string): string { - return undefined; + return undefined!; } isConnected(fileUri: string, connectionProfile?: ConnectionProfile): boolean { @@ -151,12 +156,12 @@ export class TestConnectionManagementService implements IConnectionManagementSer } findExistingConnection(connection: IConnectionProfile, purpose?: 'dashboard' | 'insights' | 'connection'): ConnectionProfile { - return undefined; + return undefined!; } connect(connection: IConnectionProfile, uri: string, options?: IConnectionCompletionOptions, callbacks?: IConnectionCallbacks): Promise { return new Promise((resolve, reject) => { - resolve({ connected: true, errorMessage: undefined, errorCode: undefined, callStack: undefined }); + resolve({ connected: true, errorMessage: undefined!, errorCode: undefined!, callStack: undefined! }); }); } @@ -168,20 +173,12 @@ export class TestConnectionManagementService implements IConnectionManagementSer return new Promise(() => true); } - disconnect(connection: IConnectionProfile); - disconnect(uri: string); - disconnect(input: any): Promise { - return new Promise((resolve, reject) => { - resolve(true); - }); - } - getConnectionProfile(fileUri: string): IConnectionProfile { - return undefined; + return undefined!; } getConnectionInfo(fileUri: string): ConnectionManagementInfo { - return undefined; + return undefined!; } addSavedPassword(connectionProfile: IConnectionProfile): Promise { @@ -189,15 +186,15 @@ export class TestConnectionManagementService implements IConnectionManagementSer } public listDatabases(connectionUri: string): Thenable { - return Promise.resolve(undefined); + return Promise.resolve(undefined!); } cancelConnection(connection: IConnectionProfile): Thenable { - return undefined; + return undefined!; } cancelEditorConnection(owner: IConnectableInput): Thenable { - return undefined; + return undefined!; } showDashboard(connection: ConnectionProfile): Promise { @@ -220,7 +217,7 @@ export class TestConnectionManagementService implements IConnectionManagementSer } getProviderIdFromUri(ownerUri: string): string { - return undefined; + return undefined!; } hasRegisteredServers(): boolean { @@ -228,7 +225,7 @@ export class TestConnectionManagementService implements IConnectionManagementSer } getCapabilities(providerName: string): azdata.DataProtocolServerCapabilities { - return undefined; + return undefined!; } canChangeConnectionConfig(profile: ConnectionProfile, newGroupID: string): boolean { @@ -243,55 +240,55 @@ export class TestConnectionManagementService implements IConnectionManagementSer } connectIfNotConnected(connection: IConnectionProfile, purpose?: 'dashboard' | 'insights' | 'connection', saveConnection: boolean = false): Promise { - return undefined; + return undefined!; } rebuildIntelliSenseCache(uri: string): Thenable { - return undefined; + return undefined!; } getTabColorForUri(uri: string): string { - return undefined; + return undefined!; } removeConnectionProfileCredentials(profile: IConnectionProfile): IConnectionProfile { - return undefined; + return undefined!; } getActiveConnectionCredentials(profileId: string): { [name: string]: string } { - return undefined; + return undefined!; } getServerInfo(profileId: string): azdata.ServerInfo { - return undefined; + return undefined!; } getConnectionString(connectionId: string): Thenable { - return undefined; + return undefined!; } buildConnectionInfo(connectionString: string, provider?: string): Thenable { - return undefined; + return undefined!; } providerRegistered(providerId: string): boolean { - return undefined; + return undefined!; } getConnectionProfileById(profileId: string): IConnectionProfile { - return undefined; + return undefined!; } getProviderProperties(providerName: string): ConnectionProviderProperties { - return undefined; + return undefined!; } getConnectionIconId(connectionId: string): string { - return undefined; + return undefined!; } getDefaultProviderId(): string { - return undefined; + return undefined!; } getConnections(activeConnectionsOnly?: boolean): ConnectionProfile[] { @@ -299,6 +296,6 @@ export class TestConnectionManagementService implements IConnectionManagementSer } getConnection(uri: string): ConnectionProfile { - return undefined; + return undefined!; } } diff --git a/src/sql/platform/connection/test/common/testConnectionProvider.ts b/src/sql/platform/connection/test/common/testConnectionProvider.ts index e6e1a2d228..b7f1a603c3 100644 --- a/src/sql/platform/connection/test/common/testConnectionProvider.ts +++ b/src/sql/platform/connection/test/common/testConnectionProvider.ts @@ -10,31 +10,31 @@ export class TestConnectionProvider implements azdata.ConnectionProvider { public readonly providerId = mssqlProviderName; connect(connectionUri: string, connectionInfo: azdata.ConnectionInfo): Thenable { - return undefined; + return Promise.resolve(true); } disconnect(connectionUri: string): Thenable { - return undefined; + return Promise.resolve(true); } cancelConnect(connectionUri: string): Thenable { - return undefined; + return Promise.resolve(true); } listDatabases(connectionUri: string): Thenable { - return undefined; + return Promise.resolve({ databaseNames: [] }); } changeDatabase(connectionUri: string, newDatabase: string): Thenable { - return undefined; + return Promise.resolve(true); } getConnectionString(connectionUri: string): Thenable { - return undefined; + return Promise.resolve(''); } rebuildIntelliSenseCache(connectionUri: string): Thenable { - return undefined; + return Promise.resolve(); } registerOnConnectionComplete(handler: (connSummary: azdata.ConnectionInfoSummary) => any) { @@ -48,4 +48,4 @@ export class TestConnectionProvider implements azdata.ConnectionProvider { registerOnConnectionChanged(handler: (changedConnInfo: azdata.ChangedConnectionInfo) => any) { return undefined; } -} \ No newline at end of file +} diff --git a/src/sql/platform/connection/test/node/connectionStatusManager.test.ts b/src/sql/platform/connection/test/node/connectionStatusManager.test.ts index 1a43501ed5..e0ec0942cc 100644 --- a/src/sql/platform/connection/test/node/connectionStatusManager.test.ts +++ b/src/sql/platform/connection/test/node/connectionStatusManager.test.ts @@ -31,11 +31,11 @@ let connectionProfile: IConnectionProfile = { groupFullName: 'g2/g2-2', groupId: 'group id', getOptionsKey: () => 'connection1', - matches: undefined, + matches: undefined!, providerName: mssqlProviderName, options: {}, saveProfile: true, - id: undefined + id: undefined! }; let editorConnectionProfile: IConnectionProfile = { connectionName: 'new name', @@ -48,11 +48,11 @@ let editorConnectionProfile: IConnectionProfile = { groupFullName: 'g2/g2-2', groupId: 'group id', getOptionsKey: () => 'connection2', - matches: undefined, + matches: undefined!, providerName: mssqlProviderName, options: {}, saveProfile: true, - id: undefined + id: undefined! }; let connectionProfileWithoutDbName: IConnectionProfile = { connectionName: 'new name', @@ -65,11 +65,11 @@ let connectionProfileWithoutDbName: IConnectionProfile = { groupFullName: 'g2/g2-2', groupId: 'group id', getOptionsKey: () => 'connection1', - matches: undefined, + matches: undefined!, providerName: mssqlProviderName, options: {}, saveProfile: true, - id: undefined + id: undefined! }; let connection1Id: string; @@ -101,7 +101,7 @@ suite('SQL ConnectionStatusManager tests', () => { test('findConnection should return connection given valid id', () => { let id: string = connection1Id; let actual = connections.findConnection(id); - assert.equal(connectionProfileObject.matches(actual.connectionProfile), true); + assert.equal(connectionProfileObject.matches(actual!.connectionProfile), true); }); test('getConnectionProfile should return undefined given invalid id', () => { @@ -114,7 +114,7 @@ suite('SQL ConnectionStatusManager tests', () => { test('getConnectionProfile should return connection given valid id', () => { let id: string = connection1Id; let actual = connections.getConnectionProfile(id); - assert.equal(connectionProfileObject.matches(actual), true); + assert.equal(connectionProfileObject.matches(actual!), true); }); test('hasConnection should return false given invalid id', () => { @@ -136,11 +136,11 @@ suite('SQL ConnectionStatusManager tests', () => { let summary: azdata.ConnectionInfoSummary = { ownerUri: connection1Id, connectionId: connection1Id, - messages: undefined, - errorMessage: undefined, - errorNumber: undefined, - serverInfo: undefined, - connectionSummary: undefined + messages: undefined!, + errorMessage: undefined!, + errorNumber: undefined!, + serverInfo: undefined!, + connectionSummary: undefined! }; connections.onConnectionComplete(summary); let actual = connections.addConnection(connectionProfile, connection1Id).connecting; @@ -152,14 +152,14 @@ suite('SQL ConnectionStatusManager tests', () => { let summary: azdata.ConnectionInfoSummary = { ownerUri: connection1Id, connectionId: connection1Id, - messages: undefined, - errorMessage: undefined, - errorNumber: undefined, - serverInfo: undefined, - connectionSummary: undefined + messages: undefined!, + errorMessage: undefined!, + errorNumber: undefined!, + serverInfo: undefined!, + connectionSummary: undefined! }; connections.onConnectionComplete(summary); - let actual = connections.findConnection(connection1Id).connecting; + let actual = connections.findConnection(connection1Id)!.connecting; assert.equal(actual, expected); actual = connections.isConnecting(connection1Id); assert.equal(actual, expected); @@ -174,8 +174,8 @@ suite('SQL ConnectionStatusManager tests', () => { let actualId = connections.updateConnectionProfile(updatedConnection, connection1Id); let newId = Utils.generateUri(updatedConnection); - let actual = connections.getConnectionProfile(newId).groupId; - let actualConnectionId = connections.getConnectionProfile(newId).id; + let actual = connections.getConnectionProfile(newId)!.groupId; + let actualConnectionId = connections.getConnectionProfile(newId)!.id; assert.equal(actual, expected); assert.equal(actualId, newId); assert.equal(actualConnectionId, expectedConnectionId); @@ -186,25 +186,25 @@ suite('SQL ConnectionStatusManager tests', () => { let summary: azdata.ConnectionInfoSummary = { connectionSummary: { databaseName: dbName, - serverName: undefined, - userName: undefined + serverName: undefined!, + userName: undefined! } , ownerUri: connection3Id, connectionId: 'connection id', - errorMessage: undefined, - errorNumber: undefined, - messages: undefined, - serverInfo: undefined + errorMessage: undefined!, + errorNumber: undefined!, + messages: undefined!, + serverInfo: undefined! }; //The original connection didn't have database name let connectionStatus = connections.findConnection(connection3Id); - connectionStatus.connectionProfile.databaseName = ''; + connectionStatus!.connectionProfile.databaseName = ''; //Verify database name changed after connection is complete connections.updateDatabaseName(summary); connectionStatus = connections.findConnection(connection3Id); - assert.equal(connectionStatus.connectionProfile.databaseName, dbName); + assert.equal(connectionStatus!.connectionProfile.databaseName, dbName); }); test('getOriginalOwnerUri should return the original uri given uri with db name', () => { @@ -212,24 +212,24 @@ suite('SQL ConnectionStatusManager tests', () => { let summary: azdata.ConnectionInfoSummary = { connectionSummary: { databaseName: dbName, - serverName: undefined, - userName: undefined + serverName: undefined!, + userName: undefined! } , ownerUri: connection3Id, connectionId: 'connection id', - errorMessage: undefined, - errorNumber: undefined, - messages: undefined, - serverInfo: undefined + errorMessage: undefined!, + errorNumber: undefined!, + messages: undefined!, + serverInfo: undefined! }; //The original connection didn't have database name - let connectionStatus = connections.findConnection(connection3Id); + let connectionStatus = connections.findConnection(connection3Id)!; connectionStatus.connectionProfile.databaseName = ''; //Verify database name changed after connection is complete connections.updateDatabaseName(summary); - connectionStatus = connections.findConnection(connection3Id); + connectionStatus = connections.findConnection(connection3Id)!; let ownerUriWithDbName = Utils.generateUriWithPrefix(connectionStatus.connectionProfile, 'connection:'); //The uri assigned to connection without db name should be the original one diff --git a/src/sql/platform/credentials/common/credentialsService.ts b/src/sql/platform/credentials/common/credentialsService.ts index f9b93e0c3d..1686e5e32e 100644 --- a/src/sql/platform/credentials/common/credentialsService.ts +++ b/src/sql/platform/credentials/common/credentialsService.ts @@ -38,7 +38,7 @@ export class CredentialsService implements ICredentialsService { private _serverEvents: { [handle: number]: CredentialManagementEvents; } = Object.create(null); - private _lastHandle: number; + private _lastHandle?: number; private _onServerEventsReady: Deferred = new Deferred(); @@ -59,14 +59,14 @@ export class CredentialsService implements ICredentialsService { } public saveCredential(credentialId: string, password: string): Promise { - return this._onServerEventsReady.promise.then(() => this._serverEvents[this._lastHandle].onSaveCredential(credentialId, password)); + return this._onServerEventsReady.promise.then(() => this._serverEvents[this._lastHandle!].onSaveCredential(credentialId, password)); } public readCredential(credentialId: string): Promise { - return this._onServerEventsReady.promise.then(() => this._serverEvents[this._lastHandle].onReadCredential(credentialId)); + return this._onServerEventsReady.promise.then(() => this._serverEvents[this._lastHandle!].onReadCredential(credentialId)); } public deleteCredential(credentialId: string): Promise { - return this._onServerEventsReady.promise.then(() => this._serverEvents[this._lastHandle].onDeleteCredential(credentialId)); + return this._onServerEventsReady.promise.then(() => this._serverEvents[this._lastHandle!].onDeleteCredential(credentialId)); } } diff --git a/src/sql/platform/credentials/test/common/testCredentialsService.ts b/src/sql/platform/credentials/test/common/testCredentialsService.ts index bc2bb2ae47..39371bd44d 100644 --- a/src/sql/platform/credentials/test/common/testCredentialsService.ts +++ b/src/sql/platform/credentials/test/common/testCredentialsService.ts @@ -42,7 +42,7 @@ export class TestCredentialsService implements ICredentialsService { } export class TestCredentialsProvider implements CredentialProvider { - handle: number; + handle: number = 0; public storedCredentials: { [K: string]: Credential } = {}; diff --git a/src/sql/platform/dashboard/browser/dashboardViewService.ts b/src/sql/platform/dashboard/browser/dashboardViewService.ts index 323b6c5bfc..861a13b23b 100644 --- a/src/sql/platform/dashboard/browser/dashboardViewService.ts +++ b/src/sql/platform/dashboard/browser/dashboardViewService.ts @@ -13,15 +13,15 @@ export const SERVICE_ID = 'dashboardViewService'; export interface IDashboardWebview extends IView { setHtml(html: string): void; onMessage: Event; - sendMessage(message: string); + sendMessage(message: string): void; } export interface IDashboardViewService { _serviceBrand: undefined; onRegisteredWebview: Event; - registerWebview(widget: IDashboardWebview); + registerWebview(widget: IDashboardWebview): void; onRegisteredModelView: Event; - registerModelView(widget: IModelView); + registerModelView(widget: IModelView): void; } export const IDashboardViewService = createDecorator(SERVICE_ID); diff --git a/src/sql/platform/dashboard/browser/insightRegistry.ts b/src/sql/platform/dashboard/browser/insightRegistry.ts index 00e9a988a8..ab00d99a97 100644 --- a/src/sql/platform/dashboard/browser/insightRegistry.ts +++ b/src/sql/platform/dashboard/browser/insightRegistry.ts @@ -90,7 +90,7 @@ class InsightRegistry implements IInsightRegistry { * @param schema config schema of the widget */ public registerInsight(id: string, description: string, schema: IJSONSchema, ctor: Type): InsightIdentifier { - this._insightSchema.properties[id] = schema; + this._insightSchema.properties![id] = schema; this._idToCtor[id] = ctor; return id; } diff --git a/src/sql/platform/dashboard/browser/modelComponentRegistry.ts b/src/sql/platform/dashboard/browser/modelComponentRegistry.ts index 5a28484713..7c01ce2cbd 100644 --- a/src/sql/platform/dashboard/browser/modelComponentRegistry.ts +++ b/src/sql/platform/dashboard/browser/modelComponentRegistry.ts @@ -18,7 +18,7 @@ export const Extensions = { export interface IComponentRegistry { registerComponentType(id: string, typeMapping: ModelComponentTypes, ctor: Type): ComponentIdentifier; getIdForTypeMapping(typeMapping: ModelComponentTypes): string; - getCtorForType(typeMapping: ModelComponentTypes): Type; + getCtorForType(typeMapping: ModelComponentTypes): Type | undefined; getCtorFromId(id: string): Type; getAllCtors(): Array>; getAllIds(): Array; @@ -38,7 +38,7 @@ class ComponentRegistry implements IComponentRegistry { return this._typeNameToId[ModelComponentTypes[typeMapping]]; } - public getCtorForType(typeMapping: ModelComponentTypes): Type { + public getCtorForType(typeMapping: ModelComponentTypes): Type | undefined { let id = this.getIdForTypeMapping(typeMapping); return id ? this._idToCtor[id] : undefined; } diff --git a/src/sql/platform/dashboard/browser/widgetRegistry.ts b/src/sql/platform/dashboard/browser/widgetRegistry.ts index 6ce28f1afd..1a99a8f5cc 100644 --- a/src/sql/platform/dashboard/browser/widgetRegistry.ts +++ b/src/sql/platform/dashboard/browser/widgetRegistry.ts @@ -55,14 +55,14 @@ class DashboardWidgetRegistry implements IDashboardWidgetRegistry { this._allSchema.extensionProperties[id] = schema; } else { if (context === undefined || context === 'database') { - this._dashboardWidgetSchema.properties[id] = schema; + this._dashboardWidgetSchema.properties![id] = schema; } if (context === undefined || context === 'server') { - this._serverWidgetSchema.properties[id] = schema; + this._serverWidgetSchema.properties![id] = schema; } - this._allSchema.properties[id] = schema; + this._allSchema.properties![id] = schema; } return id; @@ -77,11 +77,11 @@ class DashboardWidgetRegistry implements IDashboardWidgetRegistry { */ public registerNonCustomDashboardWidget(id: string, description: string, val: IInsightsConfig, context?: 'database' | 'server'): WidgetIdentifier { if (context === undefined || context === 'database') { - this._dashboardWidgetSchema.properties[id] = { type: 'null', default: null }; + this._dashboardWidgetSchema.properties![id] = { type: 'null', default: null }; } if (context === undefined || context === 'server') { - this._serverWidgetSchema.properties[id] = { type: 'null', default: null }; + this._serverWidgetSchema.properties![id] = { type: 'null', default: null }; } return id; diff --git a/src/sql/platform/tasks/browser/tasksRegistry.ts b/src/sql/platform/tasks/browser/tasksRegistry.ts index c36b997dac..1738602127 100644 --- a/src/sql/platform/tasks/browser/tasksRegistry.ts +++ b/src/sql/platform/tasks/browser/tasksRegistry.ts @@ -76,7 +76,6 @@ export const TaskRegistry: ITaskRegistry = new class implements ITaskRegistry { export abstract class Task { public readonly id: string; public readonly title: string; - public readonly iconPathDark: string; public readonly iconPath?: { dark: URI; light?: URI; }; private readonly _iconClass?: string; private readonly _description?: ITaskHandlerDescription; diff --git a/src/sql/platform/tasks/common/tasksNode.ts b/src/sql/platform/tasks/common/tasksNode.ts index 9dbe4a0514..99bb5202b5 100644 --- a/src/sql/platform/tasks/common/tasksNode.ts +++ b/src/sql/platform/tasks/common/tasksNode.ts @@ -46,7 +46,7 @@ export class TaskNode { /** * Provider Name */ - public providerName: string; + public providerName?: string; /** @@ -57,7 +57,7 @@ export class TaskNode { /** * The end time of the task */ - public endTime: string; + public endTime?: string; /** * The timer for the task @@ -72,12 +72,12 @@ export class TaskNode { /** * Children of this node */ - public children: TaskNode[]; + public children?: TaskNode[]; /** * Task's message */ - public message: string; + public message?: string; /** * Status of the task @@ -97,7 +97,7 @@ export class TaskNode { /** * Script of task operation */ - public script: string; + public script?: string; constructor(taskName: string, serverName?: string, databaseName?: string, taskId: string | undefined = undefined, taskExecutionMode: TaskExecutionMode = TaskExecutionMode.execute, isCancelable: boolean = true) { this.id = taskId || generateUuid(); diff --git a/src/sql/platform/tasks/common/tasksService.ts b/src/sql/platform/tasks/common/tasksService.ts index e9d46991b1..51f21353b9 100644 --- a/src/sql/platform/tasks/common/tasksService.ts +++ b/src/sql/platform/tasks/common/tasksService.ts @@ -127,9 +127,9 @@ export class TaskService implements ITaskService { private cancelAllTasks(): Thenable { return new Promise((resolve, reject) => { - let promises = this._taskQueue.children.map(task => { + let promises = this._taskQueue.children!.map(task => { if (task.status === TaskStatus.InProgress || task.status === TaskStatus.NotStarted) { - return this.cancelTask(task.providerName, task.id); + return this.cancelTask(task.providerName!, task.id); } return Promise.resolve(true); }); @@ -144,7 +144,7 @@ export class TaskService implements ITaskService { public handleNewTask(task: TaskNode): void { if (this._taskQueue.hasChildren) { - this._taskQueue.children.unshift(task); + this._taskQueue.children!.unshift(task); } else { this._taskQueue.hasChildren = true; this._taskQueue.children = [task]; @@ -227,7 +227,7 @@ export class TaskService implements ITaskService { private getTaskInQueue(taskId: string): TaskNode | undefined { if (this._taskQueue.hasChildren) { - return find(this._taskQueue.children, x => x.id === taskId); + return find(this._taskQueue.children!, x => x.id === taskId); } return undefined; } @@ -242,7 +242,7 @@ export class TaskService implements ITaskService { public getNumberOfInProgressTasks(): number { if (this._taskQueue.hasChildren) { - let inProgressTasks = this._taskQueue.children.filter(x => x.status === TaskStatus.InProgress); + let inProgressTasks = this._taskQueue.children!.filter(x => x.status === TaskStatus.InProgress); return inProgressTasks ? inProgressTasks.length : 0; } return 0; diff --git a/src/sql/workbench/api/common/sqlExtHostTypes.ts b/src/sql/workbench/api/common/sqlExtHostTypes.ts index 2844c0f9b4..1e812a6588 100644 --- a/src/sql/workbench/api/common/sqlExtHostTypes.ts +++ b/src/sql/workbench/api/common/sqlExtHostTypes.ts @@ -398,8 +398,8 @@ export enum AzureResource { export class TreeItem extends vsExtTypes.TreeItem { label?: string; - payload: IConnectionProfile; - providerHandle: string; + payload?: IConnectionProfile; + providerHandle?: string; } export interface ServerInfoOption { diff --git a/src/sql/workbench/contrib/charts/browser/interfaces.ts b/src/sql/workbench/contrib/charts/browser/interfaces.ts index 6a62293b9b..fbed797c7d 100644 --- a/src/sql/workbench/contrib/charts/browser/interfaces.ts +++ b/src/sql/workbench/contrib/charts/browser/interfaces.ts @@ -41,8 +41,8 @@ export interface IInsight { options: IInsightOptions; data: IInsightData; readonly types: Array; - layout(dim: Dimension); - dispose(); + layout(dim: Dimension): void; + dispose(): void; } export interface IInsightCtor { diff --git a/src/sql/workbench/contrib/charts/common/interfaces.ts b/src/sql/workbench/contrib/charts/common/interfaces.ts index 2a15ffaf9a..5cf3736207 100644 --- a/src/sql/workbench/contrib/charts/common/interfaces.ts +++ b/src/sql/workbench/contrib/charts/common/interfaces.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ export class ChartState { - dataId: { batchId: number, resultId: number }; + dataId?: { batchId: number, resultId: number }; options: IInsightOptions = { type: ChartType.Bar }; diff --git a/src/sql/workbench/contrib/dashboard/test/electron-browser/propertiesWidget.component.test.ts b/src/sql/workbench/contrib/dashboard/test/electron-browser/propertiesWidget.component.test.ts index b324d84489..101ecc3f89 100644 --- a/src/sql/workbench/contrib/dashboard/test/electron-browser/propertiesWidget.component.test.ts +++ b/src/sql/workbench/contrib/dashboard/test/electron-browser/propertiesWidget.component.test.ts @@ -11,7 +11,6 @@ import { WidgetConfig } from 'sql/workbench/contrib/dashboard/browser/core/dashb import { DashboardServiceInterface } from 'sql/workbench/contrib/dashboard/browser/services/dashboardServiceInterface.service'; import { SingleAdminService, SingleConnectionManagementService } from 'sql/workbench/services/bootstrap/browser/commonServiceInterface.service'; import { PropertiesWidgetComponent } from 'sql/workbench/contrib/dashboard/browser/widgets/properties/propertiesWidget.component'; -import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo'; import * as TypeMoq from 'typemoq'; import * as assert from 'assert'; @@ -88,11 +87,8 @@ suite('Dashboard Properties Widget Tests', () => { dashboardService.setup(x => x.adminService).returns(() => singleAdminService.object); - let connectionManagementinfo = TypeMoq.Mock.ofType(ConnectionManagementInfo); - connectionManagementinfo.object.serverInfo = serverInfo; - let singleConnectionService = TypeMoq.Mock.ofType(SingleConnectionManagementService); - singleConnectionService.setup(x => x.connectionInfo).returns(() => connectionManagementinfo.object); + singleConnectionService.setup(x => x.connectionInfo).returns(() => ({ serverInfo, providerId: undefined, connectionProfile: undefined, extensionTimer: undefined, serviceTimer: undefined, intelliSenseTimer: undefined, connecting: undefined, ownerUri: undefined })); dashboardService.setup(x => x.connectionManagementService).returns(() => singleConnectionService.object); diff --git a/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts b/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts index 1815e8495f..b4cbbb6e35 100644 --- a/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts +++ b/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts @@ -56,7 +56,7 @@ suite('SQL Connection Tree Action tests', () => { connectionManagementService.callBase = true; connectionManagementService.setup(x => x.isConnected(undefined, TypeMoq.It.isAny())).returns(() => isConnectedReturnValue); connectionManagementService.setup(x => x.connect(TypeMoq.It.isAny(), undefined, TypeMoq.It.isAny(), undefined)).returns(() => Promise.resolve(connectionResult)); - connectionManagementService.setup(x => x.disconnect(TypeMoq.It.isAny())).returns(() => Promise.resolve(true)); + connectionManagementService.setup(x => x.disconnect(TypeMoq.It.isAny())).returns(() => Promise.resolve()); connectionManagementService.setup(x => x.findExistingConnection(TypeMoq.It.isAny())).returns(() => undefined); connectionManagementService.setup(x => x.showDashboard(TypeMoq.It.isAny())).returns(() => Promise.resolve(true)); connectionManagementService.setup(x => x.isProfileConnected(TypeMoq.It.isAny())).returns(() => isConnectedReturnValue); diff --git a/src/sql/workbench/services/fileBrowser/common/fileBrowserTree.ts b/src/sql/workbench/services/fileBrowser/common/fileBrowserTree.ts index 18348a31fd..eb868f15e7 100644 --- a/src/sql/workbench/services/fileBrowser/common/fileBrowserTree.ts +++ b/src/sql/workbench/services/fileBrowser/common/fileBrowserTree.ts @@ -8,8 +8,8 @@ import { FileNode } from 'sql/workbench/services/fileBrowser/common/fileNode'; /** * File tree info needed to render initially */ -export class FileBrowserTree { - public rootNode: FileNode; - public selectedNode?: FileNode; - public expandedNodes: FileNode[]; +export interface FileBrowserTree { + rootNode: FileNode; + selectedNode?: FileNode; + expandedNodes: FileNode[]; } diff --git a/src/sql/workbench/services/fileBrowser/common/fileNode.ts b/src/sql/workbench/services/fileBrowser/common/fileNode.ts index 5a96c74d36..95b4aa93ae 100644 --- a/src/sql/workbench/services/fileBrowser/common/fileNode.ts +++ b/src/sql/workbench/services/fileBrowser/common/fileNode.ts @@ -38,7 +38,7 @@ export class FileNode { /** * Children nodes */ - public children: FileNode[]; + public children?: FileNode[]; /** * Is the node expanded @@ -53,7 +53,7 @@ export class FileNode { /** * Does this node have children */ - public hasChildren: boolean; + public hasChildren?: boolean; constructor(id: string, name: string, fullPath: string, isFile: boolean, isExpanded: boolean, ownerUri: string, parent?: FileNode) { if (id) { diff --git a/src/tsconfig.strictNullChecks.json b/src/tsconfig.strictNullChecks.json deleted file mode 100644 index 1257bbaf64..0000000000 --- a/src/tsconfig.strictNullChecks.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true, - "strictNullChecks": true, - "noImplicitAny": true, - "suppressImplicitAnyIndexErrors": true, - "skipLibCheck": true - }, - "include": [ - "./typings", - "./vs/vscode.d.ts", - "./vs/vscode.proposed.d.ts", - "./sql/azdata.d.ts", - "./sql/azdata.proposed.d.ts", - "./vs/base/**/*.ts", - // "./vs/platform/**/*.ts", - "./sql/base/**/*.ts", - "./sql/editor/**/*.ts", - "./sql/platform/accounts/common/**/*.ts", - "./sql/platform/angularEventing/**/*.ts", - "./sql/platform/backup/**/*.ts", - "./sql/platform/browser/**/*.ts", - "./sql/platform/capabilities/**/*.ts", - "./sql/platform/clipboard/**/*.ts", - "./sql/platform/common/**/*.ts", - "./sql/platform/connection/common/**/*.ts", - "./sql/platform/credentials/**/*.ts", - "./sql/platform/errorMessage/**/*.ts", - "./sql/platform/fileBrowser/**/*.ts", - "./sql/platform/metadata/**/*.ts", - "./sql/platform/model/**/*.ts", - "./sql/platform/modelComponents/**/*.ts", - "./sql/platform/notebooks/**/*.ts", - "./sql/platform/oAuth/**/*.ts", - "./sql/platform/query/common/gridDataProvider.ts", - "./sql/platform/scripting/**/*.ts", - "./sql/platform/serialization/**/*.ts", - "./sql/platform/serverGroup/**/*.ts", - "./sql/platform/tasks/**/*.ts", - "./sql/platform/telemetry/**/*.ts", - "./sql/platform/theme/**/*.ts" - ] -} diff --git a/src/tsconfig.vscode.json b/src/tsconfig.vscode.json new file mode 100644 index 0000000000..3dda04e2bd --- /dev/null +++ b/src/tsconfig.vscode.json @@ -0,0 +1,38 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": true, + "noImplicitAny": true, + "experimentalDecorators": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noImplicitThis": true, + "alwaysStrict": true, + "strictBindCallApply": true, + "strictNullChecks": true, + "strictPropertyInitialization": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true + }, + "include": [ + "./typings", + "./vs/vscode.d.ts", + "./vs/vscode.proposed.d.ts", + "./vs/monaco.d.ts", + "./sql/azdata.d.ts", + "./sql/azdata.proposed.d.ts", + "./vs/base/**/*.ts", + // "./vs/code/**/*.ts", + "./vs/editor/**/*.ts", + // "./vs/platform/**/*.ts", + "./sql/base/**/*.ts", + "./sql/editor/**/*.ts", + "./sql/platform/**/*.ts" + ], + "exclude": [ + "./sql/platform/jobManagement/**/*.ts", + "./sql/platform/query/**/*.ts", + "./sql/platform/queryHistory/**/*.ts", + "./sql/platform/restore/**/*.ts", + ] +} diff --git a/src/typings/slickgrid.d.ts b/src/typings/slickgrid.d.ts index a73a9a34a3..6bfb855462 100644 --- a/src/typings/slickgrid.d.ts +++ b/src/typings/slickgrid.d.ts @@ -1,6 +1,6 @@ // Generated by typings // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/5607f54defce88bc52a0440288f434cafffdb5ce/slickgrid/index.d.ts -interface DOMEvent extends Event {} +interface DOMEvent extends Event { } declare namespace Slick { @@ -351,7 +351,7 @@ declare namespace Slick { * @static * @constructor **/ - export var GlobalEditorLock: EditorLock; + export let GlobalEditorLock: EditorLock; /** * slick.grid.js @@ -370,7 +370,7 @@ declare namespace Slick { * @param colDef * @return **/ - asyncPostRender?: (cellNode:any, row:any, dataContext:any, colDef:any) => void; + asyncPostRender?: (cellNode: any, row: any, dataContext: any, colDef: any) => void; /** * Used by the the slick.rowMoveManager.js plugin for moving rows. Has no effect without the plugin installed. @@ -699,8 +699,7 @@ declare namespace Slick { getItems(): Array; } - export interface SlickData extends Object { - } + export type SlickData = { [key: string]: any }; export interface RowMetadata { /** @@ -757,7 +756,7 @@ declare namespace Slick { /** * Number of columns this cell will span. Can also contain "*" to indicate that the cell should span the rest of the row. */ - colspan?: number|string; + colspan?: number | string; } /** @@ -801,8 +800,8 @@ declare namespace Slick { * @param options Additional options. See Grid Options for a list of options that can be included. **/ constructor( - container: string|HTMLElement|JQuery, - data: T[]|DataProvider, + container: string | HTMLElement | JQuery, + data: T[] | DataProvider, columns: Column[], options: GridOptions); @@ -1254,7 +1253,7 @@ declare namespace Slick { // #region Editors public getEditorLock(): EditorLock; - public getEditController(): { commitCurrentEdit():boolean; cancelCurrentEdit():boolean; }; + public getEditController(): { commitCurrentEdit(): boolean; cancelCurrentEdit(): boolean; }; // #endregion Editors } @@ -1428,7 +1427,7 @@ declare namespace Slick { } - export interface OnRenderedEventArgs extends GridEventArgs{ + export interface OnRenderedEventArgs extends GridEventArgs { startRow: number; endRow: number; } @@ -1487,8 +1486,8 @@ declare namespace Slick { public init(): void; public destroy(): void; public focus(): void; - public loadValue(item:any): void; // todo: typeof(item) - public applyValue(item:any, state: string): void; // todo: typeof(item) + public loadValue(item: any): void; // todo: typeof(item) + public applyValue(item: any, state: string): void; // todo: typeof(item) public isValueChanged(): boolean; public serializeValue(): any; public validate(): ValidateResults; @@ -1549,14 +1548,14 @@ declare namespace Slick { } export interface Formatter { - (row: number, cell: number, value: any, columnDef: Column, dataContext: SlickData): string | undefined; + (row: number, cell: number, value: any, columnDef: Column, dataContext: SlickData): string | undefined; } export module Formatters { - var PercentComplete: Formatter; - var PercentCompleteBar: Formatter; - var YesNo: Formatter; - var Checkmark: Formatter; + let PercentComplete: Formatter; + let PercentCompleteBar: Formatter; + let YesNo: Formatter; + let Checkmark: Formatter; } export module Data { @@ -1580,7 +1579,7 @@ declare namespace Slick { public getPagingInfo(): PagingOptions; public getItems(): T[]; public setItems(data: T[], objectIdProperty?: string): void; - public setFilter(filterFn: (item: T, args:any) => boolean): void; // todo: typeof(args) + public setFilter(filterFn: (item: T, args: any) => boolean): void; // todo: typeof(args) public sort(comparer: Function, ascending: boolean): void; // todo: typeof(comparer), should be the same callback as Array.sort public fastSort(field: string, ascending: boolean): void; public fastSort(field: Function, ascending: boolean): void; // todo: typeof(field), should be the same callback as Array.sort @@ -1591,12 +1590,12 @@ declare namespace Slick { /** * @deprecated **/ - public groupBy(valueGetter:any, valueFormatter:any, sortComparer:any): void; + public groupBy(valueGetter: any, valueFormatter: any, sortComparer: any): void; /** * @deprecated **/ - public setAggregators(groupAggregators:any, includeCollapsed:any): void; + public setAggregators(groupAggregators: any, includeCollapsed: any): void; /** * @param level Optional level to collapse. If not specified, applies to all levels. diff --git a/src/vs/base/browser/ui/inputbox/inputBox.ts b/src/vs/base/browser/ui/inputbox/inputBox.ts index 535f215cf8..643cd87449 100644 --- a/src/vs/base/browser/ui/inputbox/inputBox.ts +++ b/src/vs/base/browser/ui/inputbox/inputBox.ts @@ -114,7 +114,7 @@ export class InputBox extends Widget { private scrollableElement: ScrollableElement | undefined; // {{SQL CARBON EDIT}} - Add showValidationMessage and set inputBackground, inputForeground, and inputBorder as protected - protected showValidationMessage: boolean; + protected showValidationMessage?: boolean; protected inputBackground?: Color; protected inputForeground?: Color; protected inputBorder?: Color;