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
committed by GitHub
parent fefe1454de
commit 64929de09d
81 changed files with 630 additions and 644 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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