fix strict null issues (#22430)

This commit is contained in:
Alan Ren
2023-03-23 15:19:23 -07:00
committed by GitHub
parent 00897fc513
commit 59ad572800
8 changed files with 56 additions and 53 deletions

View File

@@ -122,7 +122,7 @@ export class LoginDialog extends ObjectManagementDialogBase<ObjectManagement.Log
width: DefaultInputWidth
}).component();
this.disposables.push(this.nameInput.onTextChanged(async () => {
this.objectInfo.name = this.nameInput.value;
this.objectInfo.name = this.nameInput.value!;
this.onObjectValueChange();
await this.runValidation(false);
}));
@@ -149,7 +149,7 @@ export class LoginDialog extends ObjectManagementDialogBase<ObjectManagement.Log
this.enabledCheckbox = this.createCheckbox(localizedConstants.EnabledText, this.objectInfo.isEnabled);
this.disposables.push(this.enabledCheckbox.onChanged(() => {
this.objectInfo.isEnabled = this.enabledCheckbox.checked;
this.objectInfo.isEnabled = this.enabledCheckbox.checked!;
this.onObjectValueChange();
}));
this.generalSection = this.createGroup(localizedConstants.GeneralSectionHeader, [nameContainer, authTypeContainer, this.enabledCheckbox], false);
@@ -222,7 +222,7 @@ export class LoginDialog extends ObjectManagementDialogBase<ObjectManagement.Log
this.lockedOutCheckbox = this.createCheckbox(localizedConstants.LoginLockedOutText, this.objectInfo.isLockedOut, this.viewInfo.canEditLockedOutState);
items.push(this.lockedOutCheckbox);
this.disposables.push(this.lockedOutCheckbox.onChanged(() => {
this.objectInfo.isLockedOut = this.lockedOutCheckbox.checked;
this.objectInfo.isLockedOut = this.lockedOutCheckbox.checked!;
this.onObjectValueChange();
}));
}
@@ -250,7 +250,7 @@ export class LoginDialog extends ObjectManagementDialogBase<ObjectManagement.Log
this.connectPermissionCheckbox = this.createCheckbox(localizedConstants.PermissionToConnectText, this.objectInfo.connectPermission);
this.disposables.push(this.connectPermissionCheckbox.onChanged(() => {
this.objectInfo.connectPermission = this.connectPermissionCheckbox.checked;
this.objectInfo.connectPermission = this.connectPermissionCheckbox.checked!;
this.onObjectValueChange();
}));
items.push(defaultDatabaseContainer, defaultLanguageContainer, this.connectPermissionCheckbox);

View File

@@ -53,7 +53,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
protected readonly objectManagementService: IObjectManagementService,
protected readonly connectionUri: string,
protected isNewObject: boolean,
protected readonly objectName: string | undefined = undefined,
protected readonly objectName: string = '',
protected readonly objectExplorerContext?: azdata.ObjectExplorerContext,
dialogWidth: azdata.window.DialogWidth = 'narrow') {
const objectTypeDisplayName = getNodeTypeDisplayName(objectType, true);
@@ -204,7 +204,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
level: azdata.window.MessageLevel.Error
};
} else {
this.dialogObject.message = undefined;
this.dialogObject.message = { text: '' };
}
return errors.length === 0;
}
@@ -270,7 +270,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
height: getTableHeight(tableData.length)
}
).component();
this.disposables.push(table.onCellAction((arg: azdata.ICheckboxCellActionEventArgs) => {
this.disposables.push(table.onCellAction!((arg: azdata.ICheckboxCellActionEventArgs) => {
const name = listValues[arg.row];
const idx = selectedValues.indexOf(name);
if (arg.checked && idx === -1) {
@@ -283,7 +283,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
return table;
}
protected createDropdown(ariaLabel: string, values: string[], value: string, enabled: boolean = true, width: number = DefaultInputWidth): azdata.DropDownComponent {
protected createDropdown(ariaLabel: string, values: string[], value: string | undefined, enabled: boolean = true, width: number = DefaultInputWidth): azdata.DropDownComponent {
// Automatically add an empty item to the beginning of the list if the current value is not specified.
// This is needed when no meaningful default value can be provided.
if (!value) {

View File

@@ -53,7 +53,7 @@ export class UserDialog extends ObjectManagementDialogBase<ObjectManagement.User
if (this.objectInfo.password !== this.confirmPasswordInput.value) {
errors.push(localizedConstants.PasswordsNotMatchError);
}
if (!isValidSQLPassword(this.objectInfo.password, this.objectInfo.name)
if (!isValidSQLPassword(this.objectInfo.password!, this.objectInfo.name)
&& (this.isNewObject || this.objectInfo.password !== this.originalObjectInfo.password)) {
errors.push(localizedConstants.InvalidPasswordError);
}
@@ -96,12 +96,12 @@ export class UserDialog extends ObjectManagementDialogBase<ObjectManagement.User
width: DefaultInputWidth
}).component();
this.disposables.push(this.nameInput.onTextChanged(async () => {
this.objectInfo.name = this.nameInput.value;
this.objectInfo.name = this.nameInput.value!;
this.onObjectValueChange();
await this.runValidation(false);
}));
const nameContainer = this.createLabelInputContainer(localizedConstants.NameText, this.nameInput);
this.defaultSchemaDropdown = this.createDropdown(localizedConstants.DefaultSchemaText, this.viewInfo.schemas, this.objectInfo.defaultSchema);
this.defaultSchemaDropdown = this.createDropdown(localizedConstants.DefaultSchemaText, this.viewInfo.schemas, this.objectInfo.defaultSchema!);
this.defaultSchemaContainer = this.createLabelInputContainer(localizedConstants.DefaultSchemaText, this.defaultSchemaDropdown);
this.disposables.push(this.defaultSchemaDropdown.onValueChanged(() => {
this.objectInfo.defaultSchema = <string>this.defaultSchemaDropdown.value;