settings_profile_fields: Fix TypeScript noUncheckedIndexedAccess errors.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-05-30 10:07:59 -07:00
parent d49ad41a68
commit e6358f5edc
1 changed files with 7 additions and 3 deletions

View File

@ -183,8 +183,10 @@ function set_up_create_field_form(): void {
$field_url_pattern_elem.show(); $field_url_pattern_elem.show();
} else { } else {
$field_url_pattern_elem.hide(); $field_url_pattern_elem.hide();
const profile_field_name = const external_account =
realm.realm_default_external_accounts[profile_field_external_account_type].name; realm.realm_default_external_accounts[profile_field_external_account_type];
assert(external_account !== undefined);
const profile_field_name = external_account.name;
$("#profile_field_name").val(profile_field_name).prop("disabled", true); $("#profile_field_name").val(profile_field_name).prop("disabled", true);
$("#profile_field_hint").val("").prop("disabled", true); $("#profile_field_hint").val("").prop("disabled", true);
} }
@ -776,7 +778,9 @@ export function get_external_account_link(field: UserExternalAccountData): strin
assert(field.field_data.url_pattern !== undefined); assert(field.field_data.url_pattern !== undefined);
field_url_pattern = field.field_data.url_pattern; field_url_pattern = field.field_data.url_pattern;
} else { } else {
field_url_pattern = realm.realm_default_external_accounts[field_subtype].url_pattern; const external_account = realm.realm_default_external_accounts[field_subtype];
assert(external_account !== undefined);
field_url_pattern = external_account.url_pattern;
} }
return field_url_pattern.replace("%(username)s", () => field.value); return field_url_pattern.replace("%(username)s", () => field.value);
} }