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 trivial portico modules to TypeScript.

Anders Kaseorg96fadb3d66f8
diff --git a/web/src/portico/communities.js b/web/src/portico/communities.ts
similarity index 91%
rename from web/src/portico/communities.js
rename to web/src/portico/communities.ts
index 83fbbeee67f..37c216d1851 100644
--- a/web/src/portico/communities.js
+++ b/web/src/portico/communities.ts
@@ -1,6 +1,6 @@
import $ from "jquery";
-function sync_open_organizations_page_with_current_hash() {
+function sync_open_organizations_page_with_current_hash(): void {
const hash = window.location.hash;
if (!hash || hash === "#all" || hash === "#undefined") {
$(".eligible_realm").show();
diff --git a/web/src/portico/confirm-preregistrationuser.js b/web/src/portico/confirm-preregistrationuser.ts
similarity index 100%
rename from web/src/portico/confirm-preregistrationuser.js
rename to web/src/portico/confirm-preregistrationuser.ts
diff --git a/web/src/portico/desktop-redirect.js b/web/src/portico/desktop-redirect.ts
similarity index 53%
rename from web/src/portico/desktop-redirect.js
rename to web/src/portico/desktop-redirect.ts
index 3d5c4e245d6..b57eb21211a 100644
--- a/web/src/portico/desktop-redirect.js
+++ b/web/src/portico/desktop-redirect.ts
@@ -1,4 +1,4 @@
import ClipboardJS from "clipboard";
new ClipboardJS("#copy");
-document.querySelector("#copy").focus();
+document.querySelector<HTMLElement>("#copy")!.focus();
diff --git a/web/src/portico/dev-login.js b/web/src/portico/dev-login.ts
similarity index 83%
rename from web/src/portico/dev-login.js
rename to web/src/portico/dev-login.ts
index fcf11c6192e..523f7346fb6 100644
--- a/web/src/portico/dev-login.js
+++ b/web/src/portico/dev-login.ts
@@ -3,12 +3,12 @@ import $ from "jquery";
$(() => {
// This code will be executed when the user visits /login and
// dev_login.html is rendered.
- if ($("[data-page-id='dev-login']").length > 0 && window.location.hash.slice(0, 1) === "#") {
+ if ($("[data-page-id='dev-login']").length > 0 && window.location.hash.startsWith("#")) {
/* We append the location.hash to the input field with name next so that URL can be
preserved after user is logged in. See this:
https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */
$("input[name='next']").each(function () {
- const new_value = $(this).attr("value") + window.location.hash;
+ const new_value = $(this).attr("value")! + window.location.hash;
$(this).attr("value", new_value);
});
}
diff --git a/web/src/portico/header.js b/web/src/portico/header.ts
similarity index 100%
rename from web/src/portico/header.js
rename to web/src/portico/header.ts
diff --git a/web/src/portico/tippyjs.js b/web/src/portico/tippyjs.ts
similarity index 92%
rename from web/src/portico/tippyjs.js
rename to web/src/portico/tippyjs.ts
index e021b4e89c6..e8aae7010f7 100644
--- a/web/src/portico/tippyjs.js
+++ b/web/src/portico/tippyjs.ts
@@ -1,7 +1,7 @@
import $ from "jquery";
import tippy from "tippy.js";
-function initialize() {
+function initialize(): void {
tippy("[data-tippy-content]", {
// Same defaults as set in web app tippyjs module.
maxWidth: 300,