diff --git a/tools/test-js-with-node b/tools/test-js-with-node index fa60007c2b..e1560e5aba 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.ts index 78eab8a4cd..db6570f112 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.ts similarity index 72% rename from web/src/user_sort.js rename to web/src/user_sort.ts index fc7db661ff..750b62ddb6 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); }