settings_linkifiers: Fix implicit use of any.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-05-05 00:48:22 -07:00
committed by Tim Abbott
parent 515eecd15c
commit 70d140ec59

View File

@@ -70,9 +70,12 @@ function open_linkifier_edit_form(linkifier_id: number): void {
},
error_continuation(xhr: JQuery.jqXHR<unknown>) {
$change_linkifier_button.prop("disabled", false);
if (xhr.responseJSON?.errors) {
const parsed = z
.object({errors: z.record(z.array(z.string()).optional())})
.safeParse(xhr.responseJSON);
if (parsed.success) {
handle_linkifier_api_error(
xhr,
parsed.data.errors,
$pattern_status,
$template_status,
$dialog_error_element,
@@ -119,7 +122,7 @@ function update_linkifiers_order(): void {
}
function handle_linkifier_api_error(
xhr: JQuery.jqXHR<unknown>,
errors: Record<string, string[] | undefined>,
pattern_status: JQuery,
template_status: JQuery,
linkifier_status: JQuery,
@@ -127,7 +130,6 @@ function handle_linkifier_api_error(
// The endpoint uses the Django ValidationError system for error
// handling, which returns somewhat complicated error
// dictionaries. This logic parses them.
const errors = xhr.responseJSON.errors;
if (errors.pattern !== undefined) {
ui_report.error(
$t_html({defaultMessage: "Failed: {error}"}, {error: errors.pattern[0]}),
@@ -272,9 +274,12 @@ export function build_page(): void {
},
error(xhr) {
$add_linkifier_button.prop("disabled", false);
if (xhr.responseJSON?.errors) {
const parsed = z
.object({errors: z.record(z.array(z.string()).optional())})
.safeParse(xhr.responseJSON);
if (parsed.success) {
handle_linkifier_api_error(
xhr,
parsed.data.errors,
$pattern_status,
$template_status,
$linkifier_status,