diff --git a/tools/test-js-with-node b/tools/test-js-with-node index 6e7638f784..883f21763f 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -49,7 +49,7 @@ EXEMPT_FILES = make_set( "web/src/add_subscribers_pill.js", "web/src/admin.js", "web/src/alert_popup.ts", - "web/src/alert_words_ui.js", + "web/src/alert_words_ui.ts", "web/src/archive.js", "web/src/assets.d.ts", "web/src/attachments_ui.ts", diff --git a/web/src/alert_words_ui.js b/web/src/alert_words_ui.ts similarity index 85% rename from web/src/alert_words_ui.js rename to web/src/alert_words_ui.ts index 7794ef12d2..0398a68bf1 100644 --- a/web/src/alert_words_ui.js +++ b/web/src/alert_words_ui.ts @@ -12,7 +12,7 @@ import * as ui_report from "./ui_report"; export let loaded = false; -export function rerender_alert_words_ui() { +export function rerender_alert_words_ui(): void { if (!loaded) { return; } @@ -35,7 +35,7 @@ export function rerender_alert_words_ui() { }); } -function update_alert_word_status(status_text, is_error) { +function update_alert_word_status(status_text: string, is_error: boolean): void { const $alert_word_status = $("#alert_word_status"); if (is_error) { $alert_word_status.removeClass("alert-success").addClass("alert-danger"); @@ -46,8 +46,8 @@ function update_alert_word_status(status_text, is_error) { $alert_word_status.show(); } -function add_alert_word() { - const alert_word = $("#add-alert-word-name").val().trim(); +function add_alert_word(): void { + const alert_word = $("input#add-alert-word-name").val()!.trim(); if (alert_words.has_alert_word(alert_word)) { ui_report.client_error( @@ -64,9 +64,9 @@ function add_alert_word() { dialog_widget.submit_api_request(channel.post, "/json/users/me/alert_words", data); } -function remove_alert_word(alert_word) { +function remove_alert_word(alert_word: string): void { const words_to_be_removed = [alert_word]; - channel.del({ + void channel.del({ url: "/json/users/me/alert_words", data: {alert_words: JSON.stringify(words_to_be_removed)}, success() { @@ -84,18 +84,18 @@ function remove_alert_word(alert_word) { }); } -export function show_add_alert_word_modal() { +export function show_add_alert_word_modal(): void { const html_body = render_add_alert_word(); - function add_alert_word_post_render() { - const $add_user_group_input_element = $("#add-alert-word-name"); + function add_alert_word_post_render(): void { + const $add_user_group_input_element = $("input#add-alert-word-name"); const $add_user_group_submit_button = $("#add-alert-word .dialog_submit_button"); $add_user_group_submit_button.prop("disabled", true); $add_user_group_input_element.on("input", () => { $add_user_group_submit_button.prop( "disabled", - $add_user_group_input_element.val().trim() === "", + $add_user_group_input_element.val()!.trim() === "", ); }); } @@ -114,7 +114,7 @@ export function show_add_alert_word_modal() { }); } -export function set_up_alert_words() { +export function set_up_alert_words(): void { // The settings page must be rendered before this function gets called. loaded = true; rerender_alert_words_ui(); @@ -135,6 +135,6 @@ export function set_up_alert_words() { }); } -export function reset() { +export function reset(): void { loaded = false; }