Add more folders to strict compile (#8954)

* add more folders to strictire compile, add more strict compile options

* update ci

* remove unnecessary assertion
This commit is contained in:
Anthony Dresser 2020-01-27 16:26:49 -08:00 коммит произвёл GitHub
Родитель fefe1454de
Коммит 64929de09d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
81 изменённых файлов: 630 добавлений и 644 удалений

12
.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

6
.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"
}
},

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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'))

Просмотреть файл

@ -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

Просмотреть файл

@ -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",

2
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;

Просмотреть файл

@ -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<boolean>();
private _checkbox: sqlCheckbox;
private _checkbox?: sqlCheckbox;
constructor(
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef

Просмотреть файл

@ -31,7 +31,7 @@ export class InputBox extends vsInputBox {
private _onLoseFocus = this._register(new Emitter<OnLoseFocusParams>());
public onLoseFocus: Event<OnLoseFocusParams> = this._onLoseFocus.event;
private _isTextAreaInput: boolean;
private _isTextAreaInput = false;
private _hideErrors = false;
constructor(container: HTMLElement, contextViewProvider: IContextViewProvider, options?: IInputOptions) {

Просмотреть файл

@ -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)));

Просмотреть файл

@ -68,30 +68,29 @@ let idPool = 0;
`
})
export class PanelComponent extends Disposable {
@Input() public options: IPanelOptions;
@Input() public actions: Array<Action>;
@ContentChildren(TabComponent) private _tabs: QueryList<TabComponent>;
@ViewChild(ScrollableDirective) private scrollable: ScrollableDirective;
@Input() public options?: IPanelOptions;
@Input() public actions?: Array<Action>;
@ContentChildren(TabComponent) private readonly _tabs!: QueryList<TabComponent>;
@ViewChild(ScrollableDirective) private scrollable?: ScrollableDirective;
@Output() public onTabChange = new EventEmitter<TabComponent>();
@Output() public onTabClose = new EventEmitter<TabComponent>();
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();
}
}

Просмотреть файл

@ -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);
}
}
}

Просмотреть файл

@ -21,14 +21,14 @@ export abstract class TabChild extends Disposable {
`
})
export class TabComponent implements OnDestroy {
private _child: TabChild;
@ContentChild(TemplateRef) templateRef: TemplateRef<any>;
@Input() public title: string;
@Input() public canClose: boolean;
@Input() public actions: Array<Action>;
@Input() public iconClass: string;
private _child?: TabChild;
@ContentChild(TemplateRef) templateRef!: TemplateRef<any>;
@Input() public title!: string;
@Input() public canClose!: boolean;
@Input() public actions?: Array<Action>;
@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;

Просмотреть файл

@ -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<TabComponent> = new EventEmitter<TabComponent>();
@Output() public onCloseTab: EventEmitter<TabComponent> = new EventEmitter<TabComponent>();
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();
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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(<IViewItem>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(<IViewItem>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(<IViewItem>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();

Просмотреть файл

@ -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();

Просмотреть файл

@ -80,7 +80,7 @@ export class VirtualizedCollection<T extends Slick.SlickData> implements IObserv
private _bufferWindowAfter: DataWindow<T>;
private _lengthChanged = false;
private collectionChangedCallback: (startIndex: number, count: number) => void;
private collectionChangedCallback?: (startIndex: number, count: number) => void;
constructor(
private readonly windowSize: number,

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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<T> implements Slick.Plugin<T> {
private grid: Slick.Grid<T>;
private grid!: Slick.Grid<T>;
private handler = new Slick.EventHandler();
public init(grid: Slick.Grid<T>) {

Просмотреть файл

@ -14,10 +14,10 @@ const defaultOptions: IAutoColumnSizeOptions = {
autoSizeOnRender: false
};
export class AutoColumnSize<T extends Object> implements Slick.Plugin<T> {
private _grid: Slick.Grid<T>;
private _$container: JQuery;
private _context: CanvasRenderingContext2D;
export class AutoColumnSize<T extends Slick.SlickData> implements Slick.Plugin<T> {
private _grid!: Slick.Grid<T>;
private _$container!: JQuery;
private _context!: CanvasRenderingContext2D;
private _options: IAutoColumnSizeOptions;
private onPostEventHandler = new Slick.EventHandler();

Просмотреть файл

@ -37,12 +37,12 @@ export interface ICellRangeDecorator {
}
export class CellRangeSelector<T> implements ICellRangeSelector<T> {
private grid: Slick.Grid<T>;
private dragging: boolean;
private grid!: Slick.Grid<T>;
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<Slick.Cell>();
public onCellRangeSelected = new Slick.Event<Slick.Range>();

Просмотреть файл

@ -16,7 +16,7 @@ const defaults: ICellSelectionModelOptions = {
};
export class CellSelectionModel<T> implements Slick.SelectionModel<T, Array<Slick.Range>> {
private grid: Slick.Grid<T>;
private grid!: Slick.Grid<T>;
private selector: ICellRangeSelector<T>;
private ranges: Array<Slick.Range> = [];
private _handler = new Slick.EventHandler();

Просмотреть файл

@ -47,10 +47,10 @@ const checkboxTemplate = `<div style="display: flex; align-items: center; flex-d
export class CheckboxSelectColumn<T extends Slick.SlickData> implements Slick.Plugin<T> {
private _options: ICheckboxSelectColumnOptions;
private _grid: Slick.Grid<T>;
private _grid!: Slick.Grid<T>;
private _handler = new Slick.EventHandler();
private _selectedRowsLookup: dict.INumberDictionary<boolean> = {};
private _selectedCheckBoxLookup = {};
private _selectedCheckBoxLookup: {[key: string]: boolean} = {};
private _useState = false;
private _onChange = new Emitter<ICheckboxCellActionEventArgs>();
@ -274,7 +274,7 @@ export class CheckboxSelectColumn<T extends Slick.SlickData> implements Slick.Pl
// use data for first time rendering
// note: make sure Init is called before using this._grid
let rowVal = (this._grid) ? this._grid.getDataItem(row) : null;
let rowVal = this._grid?.getDataItem(row);
if (rowVal && this._options.title && rowVal[this._options.title] === true) {
this._selectedCheckBoxLookup[row] = true;
return strings.format(checkboxTemplate, 'checked', this.getAriaLabel(true));

Просмотреть файл

@ -12,7 +12,7 @@ import { isUndefinedOrNull } from 'vs/base/common/types';
* Implements the various additional navigation keybindings we want out of slickgrid
*/
export class CopyKeybind<T> implements Slick.Plugin<T> {
private grid: Slick.Grid<T>;
private grid!: Slick.Grid<T>;
private handler = new Slick.EventHandler();
private _onCopy = new Emitter<Slick.Range[]>();

Просмотреть файл

@ -19,16 +19,16 @@ export class HeaderFilter<T extends Slick.SlickData> {
public onFilterApplied = new Slick.Event();
public onCommand = new Slick.Event();
private grid: Slick.Grid<T>;
private grid!: Slick.Grid<T>;
private handler = new Slick.EventHandler();
private $menu?: JQuery<HTMLElement>;
private okButton: Button;
private clearButton: Button;
private cancelButton: Button;
private workingFilters: Array<string>;
private columnDef: IExtendedColumn<T>;
private buttonStyles: IButtonStyles;
private okButton?: Button;
private clearButton?: Button;
private cancelButton?: Button;
private workingFilters!: Array<string>;
private columnDef!: IExtendedColumn<T>;
private buttonStyles?: IButtonStyles;
private disposableStore = new DisposableStore();
@ -286,7 +286,7 @@ export class HeaderFilter<T extends Slick.SlickData> {
if ($checkbox.prop('checked') && index < 0) {
workingFilters.push(filterItems[value]);
const nextRow = filterItems[(parseInt(<string><any>value) + 1).toString()]; // for some reason parseInt is defined as only supporting strings even though it works fine for numbers
const nextRow = filterItems[Number((parseInt(<string><any>value) + 1).toString())]; // for some reason parseInt is defined as only supporting strings even though it works fine for numbers
if (nextRow && nextRow.indexOf('Error:') >= 0) {
workingFilters.push(nextRow);
}

Просмотреть файл

@ -21,8 +21,8 @@ const defaultOptions: IMouseWheelSupportOptions = {
export class MouseWheelSupport implements Slick.Plugin<any> {
private viewport: HTMLElement;
private canvas: HTMLElement;
private viewport!: HTMLElement;
private canvas!: HTMLElement;
private options: IMouseWheelSupportOptions;
private _disposables = new DisposableStore();

Просмотреть файл

@ -51,11 +51,11 @@ export class RowDetailView<T extends Slick.SlickData> {
public readonly onAfterRowDetailToggle = new Slick.Event<{ grid: Slick.Grid<T>, item: T }>();
public readonly onBeforeRowDetailToggle = new Slick.Event<{ grid: Slick.Grid<T>, item: T }>();
private _grid: Slick.Grid<T>;
private _grid!: Slick.Grid<T>;
private _expandedRows: Array<ExtendedItem<T>> = [];
private _handler = new Slick.EventHandler();
private _dataView: AugmentedDataView<T>;
private _dataView!: AugmentedDataView<T>;
private _options: IRowDetailViewOptions<T>;
constructor(options: IRowDetailViewOptions<T>) {

Просмотреть файл

@ -10,7 +10,7 @@ export interface IRowNumberColumnOptions {
export class RowNumberColumn<T> implements Slick.Plugin<T> {
private handler = new Slick.EventHandler();
private grid: Slick.Grid<T>;
private grid!: Slick.Grid<T>;
constructor(private options: IRowNumberColumnOptions) {
}

Просмотреть файл

@ -12,7 +12,7 @@ export interface IRowSelectionModelOptions extends Slick.PluginOptions {
export class RowSelectionModel<T extends Slick.SlickData> implements Slick.SelectionModel<T, Array<Slick.Range>> {
private _options: IRowSelectionModelOptions;
private _grid: Slick.Grid<T>;
private _grid!: Slick.Grid<T>;
private _handler = new Slick.EventHandler();
private _ranges: Array<Slick.Range> = [];

Просмотреть файл

@ -35,9 +35,9 @@ export class Table<T extends Slick.SlickData> extends Widget implements IDisposa
private _grid: Slick.Grid<T>;
private _columns: Slick.Column<T>[];
private _data: IDisposableDataProvider<T>;
private _sorter: ITableSorter<T>;
private _sorter?: ITableSorter<T>;
private _autoscroll: boolean;
private _autoscroll?: boolean;
private _container: HTMLElement;
private _tableContainer: HTMLElement;
@ -97,7 +97,7 @@ export class Table<T extends Slick.SlickData> extends Widget implements IDisposa
if (configuration && configuration.sorter) {
this._sorter = configuration.sorter;
this._grid.onSort.subscribe((e, args) => {
this._sorter(args);
this._sorter!(args);
this._grid.invalidate();
this._grid.render();
});

Просмотреть файл

@ -45,9 +45,9 @@ export class TableDataView<T extends Slick.SlickData> implements IDisposableData
//The data exposed publicly, when filter is enabled, _data holds the filtered data.
private _data: Array<T>;
//Used when filtering is enabled, _allData holds the complete set of data.
private _allData: Array<T>;
private _findArray: Array<IFindPosition>;
private _findIndex: number;
private _allData!: Array<T>;
private _findArray?: Array<IFindPosition>;
private _findIndex?: number;
private _filterEnabled: boolean;
private _onRowCountChange = new Emitter<number>();
@ -166,7 +166,7 @@ export class TableDataView<T extends Slick.SlickData> implements IDisposableData
if (exp) {
return new Promise<IFindPosition>((resolve) => {
const disp = this.onFindCountChange(e => {
resolve(this._findArray[e - 1]);
resolve(this._findArray![e - 1]);
disp.dispose();
});
this._startSearch(exp, maxMatches);
@ -185,9 +185,9 @@ export class TableDataView<T extends Slick.SlickData> implements IDisposableData
for (let j = 0; j < result.length; j++) {
const pos = result[j];
const index = { col: pos, row: i };
this._findArray.push(index);
this._onFindCountChange.fire(this._findArray.length);
if (maxMatches > 0 && this._findArray.length === maxMatches) {
this._findArray!.push(index);
this._onFindCountChange.fire(this._findArray!.length);
if (maxMatches > 0 && this._findArray!.length === maxMatches) {
breakout = true;
break;
}
@ -211,9 +211,9 @@ export class TableDataView<T extends Slick.SlickData> implements IDisposableData
if (this._findIndex === this._findArray.length - 1) {
this._findIndex = 0;
} else {
++this._findIndex;
++this._findIndex!;
}
return Promise.resolve(this._findArray[this._findIndex]);
return Promise.resolve(this._findArray[this._findIndex!]);
} else {
return Promise.reject(new Error('no search running'));
}
@ -224,9 +224,9 @@ export class TableDataView<T extends Slick.SlickData> implements IDisposableData
if (this._findIndex === 0) {
this._findIndex = this._findArray.length - 1;
} else {
--this._findIndex;
--this._findIndex!;
}
return Promise.resolve(this._findArray[this._findIndex]);
return Promise.resolve(this._findArray[this._findIndex!]);
} else {
return Promise.reject(new Error('no search running'));
}
@ -234,7 +234,7 @@ export class TableDataView<T extends Slick.SlickData> implements IDisposableData
get currentFindPosition(): Thenable<IFindPosition> {
if (this._findArray && this._findArray.length !== 0) {
return Promise.resolve(this._findArray[this._findIndex]);
return Promise.resolve(this._findArray[this._findIndex!]);
} else {
return Promise.reject(new Error('no search running'));
}

Просмотреть файл

@ -8,8 +8,8 @@
*/
export class Deferred<T> implements Promise<T> {
promise: Promise<T>;
resolve: (value?: T | PromiseLike<T>) => void;
reject: (reason?: any) => void;
resolve!: (value?: T | PromiseLike<T>) => void;
reject!: (reason?: any) => void;
constructor() {
this.promise = new Promise<T>((resolve, reject) => {
this.resolve = resolve;

Просмотреть файл

@ -87,7 +87,7 @@ export class Dropdown extends Disposable {
private _filter = new DropdownFilter();
private _renderer = new DropdownRenderer();
private _controller = new DropdownController();
public fireOnTextChange: boolean;
public fireOnTextChange?: boolean;
private _onBlur = this._register(new Emitter<void>());
public onBlur: Event<void> = this._onBlur.event;

Просмотреть файл

@ -57,7 +57,7 @@ export class DropdownRenderer implements tree.IRenderer {
}
export class DropdownDataSource implements tree.IDataSource {
public options: Array<Resource>;
public options?: Array<Resource>;
public getId(tree: tree.ITree, element: Resource | DropdownModel): string {
if (element instanceof DropdownModel) {
@ -93,10 +93,14 @@ export class DropdownDataSource implements tree.IDataSource {
}
export class DropdownFilter extends TreeDefaults.DefaultFilter {
public filterString: string;
public filterString?: string;
public isVisible(tree: tree.ITree | undefined, element: Resource): boolean {
return element.value.toLowerCase().indexOf(this.filterString.toLowerCase()) !== -1;
if (this.filterString) {
return element.value.toLowerCase().indexOf(this.filterString.toLowerCase()) !== -1;
} else {
return true;
}
}
}

Просмотреть файл

@ -11,9 +11,10 @@ const testText = '<div>test text</div>';
suite('Grid shared services tests', () => {
test('textFormatter should encode HTML when formatting a DBCellValue object', () => {
// If I format a DBCellValue object that contains HTML
let cellValue = new SharedServices.DBCellValue();
cellValue.displayValue = testText;
cellValue.isNull = false;
let cellValue = {
displayValue: testText,
isNull: false
};
let formattedHtml = SharedServices.textFormatter(undefined, undefined, cellValue, undefined, undefined);
// Then the result is HTML for a span element containing the cell value's display value as plain text

Просмотреть файл

@ -178,7 +178,7 @@ suite('TableDataView', () => {
function populateData(row: number, column: number): any[] {
let data: Array<{ [key: string]: string }> = [];
for (let i: number = 0; i < row; i++) {
let row = {};
let row: { [key: string]: string } = {};
for (let j: number = 0; j < column; j++) {
row[getColumnName(j)] = getCellValue(i, j);
}

Просмотреть файл

@ -6,14 +6,14 @@
import * as assert from 'assert';
export class EventVerifierSingle<T> {
private _eventArgument: T;
private _eventArgument?: T;
private _eventFired: boolean;
constructor() {
this._eventFired = false;
}
public get eventArgument(): T {
public get eventArgument(): T | undefined {
return this._eventArgument;
}
@ -28,7 +28,7 @@ export class EventVerifierSingle<T> {
}
}
public assertFiredWithVerify(argumentVerification: (arg: T) => void) {
public assertFiredWithVerify(argumentVerification: (arg: T | undefined) => void) {
assert.ok(this._eventFired);
argumentVerification(this._eventArgument);
}

Просмотреть файл

@ -130,7 +130,7 @@ export class ApplyFilterAction extends Action {
export class RefreshAccountAction extends Action {
public static ID = 'account.refresh';
public static LABEL = localize('refreshAccount', "Reenter your credentials");
public account: azdata.Account;
public account?: azdata.Account;
constructor(
@IAccountManagementService private _accountManagementService: IAccountManagementService,

Просмотреть файл

@ -14,9 +14,9 @@ export default class AccountStore implements IAccountStore {
public static MEMENTO_KEY: string = 'Microsoft.SqlTools.Accounts';
// MEMBER VARIABLES ////////////////////////////////////////////////////
private _activeOperation: Thenable<any>;
private _activeOperation?: Thenable<any>;
constructor(private _memento: object) { }
constructor(private _memento: { [key: string]: any }) { }
// PUBLIC METHODS //////////////////////////////////////////////////////
public addOrUpdate(newAccount: azdata.Account): Thenable<AccountAdditionResult> {

Просмотреть файл

@ -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 {

Просмотреть файл

@ -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 = <azdata.Account>{
};
function getTestMemento() {
let memento = {};
let memento: { [key: string]: azdata.Account[] } = {};
memento[AccountStore.MEMENTO_KEY] = [account1, account2];
return memento;

Просмотреть файл

@ -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<string>();
private _previousVal: string;
private _previousVal?: string;
constructor(
@Inject(forwardRef(() => ElementRef)) private readonly _el: ElementRef,

Просмотреть файл

@ -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<string | number>();
@ -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!;
}
}
}

Просмотреть файл

@ -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<ISelectData>();
private _previousVal: string;
private _previousVal?: string;
constructor(
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -11,7 +11,7 @@ export interface IConnectionProfile extends azdata.IConnectionProfile {
}
export interface IConnectionProfileStore {
options: {};
options: { [key: string]: any };
groupId: string;
providerName: string;
savePassword: boolean;

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length + 1);
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('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<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length);
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('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<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length + 1);
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connectionGroups').userValue.length, testGroups.length + 1);
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length + 1);
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('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<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length - 1);
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('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<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length - 1);
assert.equal(configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue.length, testGroups.length - 2);
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').userValue!.length, testConnections.length - 1);
assert.equal(configurationService.inspect<IConnectionProfileGroup[]>('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<IConnectionProfileStore[]>('datasource.connections').userValue.length, testConnections.length);
assert.equal(configurationService.inspect<IConnectionProfileStore[]>('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<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue;
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('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<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue;
let groups = configurationService.inspect<IConnectionProfileGroup[]>('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<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue;
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('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<IConnectionProfileStore[]>('datasource.connections').userValue;
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('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<IConnectionProfileStore[]>('datasource.connections').userValue;
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('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<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue;
let editGroups = configurationService.inspect<IConnectionProfileGroup[]>('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<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue;
let editGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').userValue!;
assert.equal(editGroups.length, testGroups.length);
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);

Просмотреть файл

@ -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');
});

Просмотреть файл

@ -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);

Просмотреть файл

@ -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<void> {
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++) {

Просмотреть файл

@ -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<void>;
disconnect(ownerUri: string): Promise<void>;
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<any> {
return Event.None;
@ -43,15 +48,15 @@ export class TestConnectionManagementService implements IConnectionManagementSer
}
showConnectionDialog(params?: INewConnectionParams, options?: IConnectionCompletionOptions, model?: IConnectionProfile, connectionResult?: IConnectionResult): Promise<void> {
return undefined;
return undefined!;
}
showCreateServerGroupDialog(): Promise<void> {
return undefined;
return undefined!;
}
showEditServerGroupDialog(group: ConnectionProfileGroup): Promise<void> {
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<string> {
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<IConnectionResult> {
return new Promise<IConnectionResult>((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<boolean>(() => true);
}
disconnect(connection: IConnectionProfile);
disconnect(uri: string);
disconnect(input: any): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
resolve(true);
});
}
getConnectionProfile(fileUri: string): IConnectionProfile {
return undefined;
return undefined!;
}
getConnectionInfo(fileUri: string): ConnectionManagementInfo {
return undefined;
return undefined!;
}
addSavedPassword(connectionProfile: IConnectionProfile): Promise<IConnectionProfile> {
@ -189,15 +186,15 @@ export class TestConnectionManagementService implements IConnectionManagementSer
}
public listDatabases(connectionUri: string): Thenable<azdata.ListDatabasesResult> {
return Promise.resolve(undefined);
return Promise.resolve(undefined!);
}
cancelConnection(connection: IConnectionProfile): Thenable<boolean> {
return undefined;
return undefined!;
}
cancelEditorConnection(owner: IConnectableInput): Thenable<boolean> {
return undefined;
return undefined!;
}
showDashboard(connection: ConnectionProfile): Promise<boolean> {
@ -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<string> {
return undefined;
return undefined!;
}
rebuildIntelliSenseCache(uri: string): Thenable<void> {
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<string> {
return undefined;
return undefined!;
}
buildConnectionInfo(connectionString: string, provider?: string): Thenable<azdata.ConnectionInfo> {
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!;
}
}

Просмотреть файл

@ -10,31 +10,31 @@ export class TestConnectionProvider implements azdata.ConnectionProvider {
public readonly providerId = mssqlProviderName;
connect(connectionUri: string, connectionInfo: azdata.ConnectionInfo): Thenable<boolean> {
return undefined;
return Promise.resolve(true);
}
disconnect(connectionUri: string): Thenable<boolean> {
return undefined;
return Promise.resolve(true);
}
cancelConnect(connectionUri: string): Thenable<boolean> {
return undefined;
return Promise.resolve(true);
}
listDatabases(connectionUri: string): Thenable<azdata.ListDatabasesResult> {
return undefined;
return Promise.resolve({ databaseNames: [] });
}
changeDatabase(connectionUri: string, newDatabase: string): Thenable<boolean> {
return undefined;
return Promise.resolve(true);
}
getConnectionString(connectionUri: string): Thenable<string> {
return undefined;
return Promise.resolve('');
}
rebuildIntelliSenseCache(connectionUri: string): Thenable<void> {
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;
}
}
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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<void> = new Deferred<void>();
@ -59,14 +59,14 @@ export class CredentialsService implements ICredentialsService {
}
public saveCredential(credentialId: string, password: string): Promise<boolean> {
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<azdata.Credential> {
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<boolean> {
return this._onServerEventsReady.promise.then(() => this._serverEvents[this._lastHandle].onDeleteCredential(credentialId));
return this._onServerEventsReady.promise.then(() => this._serverEvents[this._lastHandle!].onDeleteCredential(credentialId));
}
}

Просмотреть файл

@ -42,7 +42,7 @@ export class TestCredentialsService implements ICredentialsService {
}
export class TestCredentialsProvider implements CredentialProvider {
handle: number;
handle: number = 0;
public storedCredentials: { [K: string]: Credential } = {};

Просмотреть файл

@ -13,15 +13,15 @@ export const SERVICE_ID = 'dashboardViewService';
export interface IDashboardWebview extends IView {
setHtml(html: string): void;
onMessage: Event<string>;
sendMessage(message: string);
sendMessage(message: string): void;
}
export interface IDashboardViewService {
_serviceBrand: undefined;
onRegisteredWebview: Event<IDashboardWebview>;
registerWebview(widget: IDashboardWebview);
registerWebview(widget: IDashboardWebview): void;
onRegisteredModelView: Event<IModelView>;
registerModelView(widget: IModelView);
registerModelView(widget: IModelView): void;
}
export const IDashboardViewService = createDecorator<IDashboardViewService>(SERVICE_ID);

Просмотреть файл

@ -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<IInsightsView>): InsightIdentifier {
this._insightSchema.properties[id] = schema;
this._insightSchema.properties![id] = schema;
this._idToCtor[id] = ctor;
return id;
}

Просмотреть файл

@ -18,7 +18,7 @@ export const Extensions = {
export interface IComponentRegistry {
registerComponentType(id: string, typeMapping: ModelComponentTypes, ctor: Type<IComponent>): ComponentIdentifier;
getIdForTypeMapping(typeMapping: ModelComponentTypes): string;
getCtorForType(typeMapping: ModelComponentTypes): Type<IComponent>;
getCtorForType(typeMapping: ModelComponentTypes): Type<IComponent> | undefined;
getCtorFromId(id: string): Type<IComponent>;
getAllCtors(): Array<Type<IComponent>>;
getAllIds(): Array<string>;
@ -38,7 +38,7 @@ class ComponentRegistry implements IComponentRegistry {
return this._typeNameToId[ModelComponentTypes[typeMapping]];
}
public getCtorForType(typeMapping: ModelComponentTypes): Type<IComponent> {
public getCtorForType(typeMapping: ModelComponentTypes): Type<IComponent> | undefined {
let id = this.getIdForTypeMapping(typeMapping);
return id ? this._idToCtor[id] : undefined;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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();

Просмотреть файл

@ -127,9 +127,9 @@ export class TaskService implements ITaskService {
private cancelAllTasks(): Thenable<void> {
return new Promise<void>((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;

Просмотреть файл

@ -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 {

Просмотреть файл

@ -41,8 +41,8 @@ export interface IInsight {
options: IInsightOptions;
data: IInsightData;
readonly types: Array<InsightType | ChartType>;
layout(dim: Dimension);
dispose();
layout(dim: Dimension): void;
dispose(): void;
}
export interface IInsightCtor {

Просмотреть файл

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
export class ChartState {
dataId: { batchId: number, resultId: number };
dataId?: { batchId: number, resultId: number };
options: IInsightOptions = {
type: ChartType.Bar
};

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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[];
}

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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"
]
}

38
src/tsconfig.vscode.json Normal file
Просмотреть файл

@ -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",
]
}

39
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<Slick.SlickData>;
export let GlobalEditorLock: EditorLock<Slick.SlickData>;
/**
* 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<T>;
}
export interface SlickData extends Object {
}
export type SlickData = { [key: string]: any };
export interface RowMetadata<T> {
/**
@ -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<T>,
container: string | HTMLElement | JQuery,
data: T[] | DataProvider<T>,
columns: Column<T>[],
options: GridOptions<T>);
@ -1254,7 +1253,7 @@ declare namespace Slick {
// #region Editors
public getEditorLock(): EditorLock<any>;
public getEditController(): { commitCurrentEdit():boolean; cancelCurrentEdit():boolean; };
public getEditController(): { commitCurrentEdit(): boolean; cancelCurrentEdit(): boolean; };
// #endregion Editors
}
@ -1428,7 +1427,7 @@ declare namespace Slick {
}
export interface OnRenderedEventArgs<T extends SlickData> extends GridEventArgs<T>{
export interface OnRenderedEventArgs<T extends SlickData> extends GridEventArgs<T> {
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<T extends SlickData> {
(row: number, cell: number, value: any, columnDef: Column<T>, dataContext: SlickData): string | undefined;
(row: number, cell: number, value: any, columnDef: Column<T>, dataContext: SlickData): string | undefined;
}
export module Formatters {
var PercentComplete: Formatter<Slick.SlickData>;
var PercentCompleteBar: Formatter<Slick.SlickData>;
var YesNo: Formatter<Slick.SlickData>;
var Checkmark: Formatter<Slick.SlickData>;
let PercentComplete: Formatter<Slick.SlickData>;
let PercentCompleteBar: Formatter<Slick.SlickData>;
let YesNo: Formatter<Slick.SlickData>;
let Checkmark: Formatter<Slick.SlickData>;
}
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.

Просмотреть файл

@ -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;