Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
ts: Migrate ‘user_sort.js’ to TypeScript.
Aryan Bhokare646128db9e9d
diff --git a/tools/test-js-with-node b/tools/test-js-with-nodeindex fa60007c2bb..e1560e5aba1 100755--- a/tools/test-js-with-node+++ b/tools/test-js-with-node@@ -269,7 +269,7 @@ EXEMPT_FILES = make_set("web/src/user_groups.ts","web/src/user_profile.js","web/src/user_settings.ts",- "web/src/user_sort.js",+ "web/src/user_sort.ts","web/src/user_status.ts","web/src/user_status_ui.js","web/src/user_topic_popover.js",diff --git a/web/src/people.ts b/web/src/people.tsindex 78eab8a4cdc..db6570f112b 100644--- a/web/src/people.ts+++ b/web/src/people.ts@@ -23,7 +23,7 @@ export type ProfileData = {export type User = {user_id: number;- delivery_email?: string | null;+ delivery_email: string | null;email: string;full_name: string;date_joined: string;diff --git a/web/src/user_sort.js b/web/src/user_sort.tssimilarity index 72%rename from web/src/user_sort.jsrename to web/src/user_sort.tsindex fc7db661ff3..750b62ddb6d 100644--- a/web/src/user_sort.js+++ b/web/src/user_sort.ts@@ -1,4 +1,6 @@-export function compare_a_b(a, b) {+import type {User} from "./people";++export function compare_a_b(a: number | string, b: number | string): number {if (a > b) {return 1;} else if (a === b) {@@ -7,7 +9,7 @@ export function compare_a_b(a, b) {return -1;}-export function sort_email(a, b) {+export function sort_email(a: User, b: User): number {const email_a = a.delivery_email;const email_b = b.delivery_email;@@ -27,10 +29,10 @@ export function sort_email(a, b) {return compare_a_b(email_a.toLowerCase(), email_b.toLowerCase());}-export function sort_role(a, b) {+export function sort_role(a: User, b: User): number {return compare_a_b(a.role, b.role);}-export function sort_user_id(a, b) {+export function sort_user_id(a: User, b: User): number {return compare_a_b(a.user_id, b.user_id);}