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 loading module to TypeScript.

Priyank Patel4fa43093389d
diff --git a/static/js/loading.js b/static/js/loading.ts
similarity index 88%
rename from static/js/loading.js
rename to static/js/loading.ts
index 201ecb2c31b..246c39c65b6 100644
--- a/static/js/loading.js
+++ b/static/js/loading.ts
@@ -2,7 +2,10 @@ import $ from "jquery";
import render_loader from "../templates/loader.hbs";
-export function make_indicator(outer_container, {abs_positioned = false, text} = {}) {
+export function make_indicator(
+ outer_container: JQuery,
+ {abs_positioned = false, text}: {abs_positioned?: boolean; text?: string} = {},
+): void {
let container = outer_container;
// TODO: We set white-space to 'nowrap' because under some
@@ -37,7 +40,7 @@ export function make_indicator(outer_container, {abs_positioned = false, text} =
container.append(text_elem);
// See note, below
if (!abs_positioned) {
- text_width = 20 + text_elem.width();
+ text_width = 20 + (text_elem.width() ?? 0);
}
}
@@ -48,7 +51,7 @@ export function make_indicator(outer_container, {abs_positioned = false, text} =
outer_container.data("destroying", false);
}
-export function destroy_indicator(container) {
+export function destroy_indicator(container: JQuery): void {
if (container.data("destroying")) {
return;
}
diff --git a/static/styles/app_components.css b/static/styles/app_components.css
index 3c2a41ec3a1..61ade677771 100644
--- a/static/styles/app_components.css
+++ b/static/styles/app_components.css
@@ -446,7 +446,7 @@ div.overlay {
top: 9px;
}
-/* Standard loading indicators generated by the loading.js API */
+/* Standard loading indicators generated by the loading.ts API */
.loading_indicator_spinner {
/* If you change these, make sure to adjust the constants in
loading.make_indicator as well */
diff --git a/tools/test-js-with-node b/tools/test-js-with-node
index c054853fb7c..192f15d7669 100755
--- a/tools/test-js-with-node
+++ b/tools/test-js-with-node
@@ -78,7 +78,7 @@ EXEMPT_FILES = {
"static/js/lightbox_canvas.js",
"static/js/lightbox.js",
"static/js/list_util.ts",
- "static/js/loading.js",
+ "static/js/loading.ts",
"static/js/local_message.js",
"static/js/localstorage.js",
"static/js/message_edit.js",