Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

ts: Convert ui_report module to TypeScript.

Priyank Patelf7235912ff08
diff --git a/static/js/ui_report.js b/static/js/ui_report.ts
similarity index 73%
rename from static/js/ui_report.js
rename to static/js/ui_report.ts
index d450411ea07..78ae990dd04 100644
--- a/static/js/ui_report.js
+++ b/static/js/ui_report.ts
@@ -10,7 +10,12 @@ import {$t} from "./i18n";
cls- class that we want to add/remove to/from the status_box
*/
-export function message(response_html, status_box, cls = "alert", remove_after) {
+export function message(
+ response_html: string,
+ status_box: JQuery,
+ cls = "alert",
+ remove_after?: number,
+): void {
// Note we use html() below, since we can rely on our callers escaping HTML
// via $t_html when interpolating data.
status_box
@@ -27,7 +32,12 @@ export function message(response_html, status_box, cls = "alert", remove_after)
status_box.addClass("show");
}
-export function error(response_html, xhr, status_box, remove_after) {
+export function error(
+ response_html: string,
+ xhr: JQuery.jqXHR | undefined,
+ status_box: JQuery,
+ remove_after?: number,
+): void {
if (xhr && xhr.status >= 400 && xhr.status < 500) {
// Only display the error response for 4XX, where we've crafted
// a nice response.
@@ -42,15 +52,19 @@ export function error(response_html, xhr, status_box, remove_after) {
message(response_html, status_box, "alert-error", remove_after);
}
-export function client_error(response_html, status_box, remove_after) {
+export function client_error(
+ response_html: string,
+ status_box: JQuery,
+ remove_after?: number,
+): void {
message(response_html, status_box, "alert-error", remove_after);
}
-export function success(response_html, status_box, remove_after) {
+export function success(response_html: string, status_box: JQuery, remove_after?: number): void {
message(response_html, status_box, "alert-success", remove_after);
}
-export function generic_embed_error(error_html) {
+export function generic_embed_error(error_html: string): void {
const $alert = $("<div class='alert home-error-bar'></div>");
const $exit = "<div class='exit'></div>";
@@ -59,7 +73,7 @@ export function generic_embed_error(error_html) {
);
}
-export function generic_row_button_error(xhr, btn) {
+export function generic_row_button_error(xhr: JQuery.jqXHR, btn: JQuery): void {
if (xhr.status >= 400 && xhr.status < 500) {
const $error = $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg);
btn.closest("td").empty().append($error);
@@ -68,13 +82,13 @@ export function generic_row_button_error(xhr, btn) {
}
}
-export function hide_error($target) {
+export function hide_error($target: JQuery): void {
$target.addClass("fade-out");
setTimeout(() => {
$target.removeClass("show fade-out");
}, 300);
}
-export function show_error($target) {
+export function show_error($target: JQuery): void {
$target.addClass("show");
}
diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py
index 4c9a970e6a0..779c7c79e00 100644
--- a/tools/linter_lib/custom_check.py
+++ b/tools/linter_lib/custom_check.py
@@ -132,7 +132,7 @@ js_rules = RuleList(
"exclude": {
"static/js/portico",
"static/js/lightbox.js",
- "static/js/ui_report.js",
+ "static/js/ui_report.ts",
"static/js/confirm_dialog.js",
"frontend_tests/",
},
diff --git a/tools/test-js-with-node b/tools/test-js-with-node
index 471d3f627db..1187d4fb0c3 100755
--- a/tools/test-js-with-node
+++ b/tools/test-js-with-node
@@ -164,7 +164,7 @@ EXEMPT_FILES = {
"static/js/typing.js",
"static/js/ui_init.js",
"static/js/ui.js",
- "static/js/ui_report.js",
+ "static/js/ui_report.ts",
"static/js/ui_util.js",
"static/js/unread_ops.js",
"static/js/unread_ui.js",