Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
pm_list_dom: Convert module to TypeScript.
Anders Kaseorge459b83c0605
diff --git a/tools/test-js-with-node b/tools/test-js-with-nodeindex 883f21763f4..a142e417f93 100755--- a/tools/test-js-with-node+++ b/tools/test-js-with-node@@ -142,7 +142,7 @@ EXEMPT_FILES = make_set("web/src/playground_links_popover.js","web/src/plotly.js.d.ts","web/src/pm_list.js",- "web/src/pm_list_dom.js",+ "web/src/pm_list_dom.ts","web/src/poll_widget.js","web/src/popover_menus.js","web/src/popover_menus_data.js",diff --git a/web/src/pm_list_dom.js b/web/src/pm_list_dom.tssimilarity index 50%rename from web/src/pm_list_dom.jsrename to web/src/pm_list_dom.tsindex f633b74f150..d885c8c7d51 100644--- a/web/src/pm_list_dom.js+++ b/web/src/pm_list_dom.ts@@ -5,10 +5,19 @@ import render_pm_list_item from "../templates/pm_list_item.hbs";import * as vdom from "./vdom";-export function keyed_pm_li(conversation) {- const render = () => render_pm_list_item(conversation);+// TODO/typescript: Move this to pm_list_data+type PMListConversation = {+ user_ids_string: string;+};- const eq = (other) => _.isEqual(conversation, other.conversation);+type PMNode = vdom.Node & {+ conversation: PMListConversation;+};++export function keyed_pm_li(conversation: PMListConversation): PMNode {+ const render = (): string => render_pm_list_item(conversation);++ const eq = (other: PMNode): boolean => _.isEqual(conversation, other.conversation);const key = conversation.user_ids_string;@@ -20,12 +29,20 @@ export function keyed_pm_li(conversation) {};}-export function more_private_conversations_li(more_conversations_unread_count) {- const render = () => render_more_private_conversations({more_conversations_unread_count});+type MorePrivateConversationsNode = vdom.Node & {+ more_items: boolean;+ more_conversations_unread_count: number;+};++export function more_private_conversations_li(+ more_conversations_unread_count: number,+): MorePrivateConversationsNode {+ const render = (): string =>+ render_more_private_conversations({more_conversations_unread_count});// Used in vdom.js to check if an element has changed and needs to// be updated in the DOM.- const eq = (other) =>+ const eq = (other: MorePrivateConversationsNode): boolean =>other.more_items &&more_conversations_unread_count === other.more_conversations_unread_count;@@ -41,8 +58,8 @@ export function more_private_conversations_li(more_conversations_unread_count) {};}-export function pm_ul(nodes) {- const attrs = [+export function pm_ul(nodes: vdom.Node[]): vdom.Tag {+ const attrs: [string, string][] = [["class", "pm-list"],["data-name", "private"],];diff --git a/web/src/vdom.ts b/web/src/vdom.tsindex 2ee174b10f6..160e1885939 100644--- a/web/src/vdom.ts+++ b/web/src/vdom.ts@@ -151,7 +151,7 @@ export function update(like `attrs` for attributes.For examples of creating vdom objects, look at- `pm_list_dom.js`.+ `pm_list_dom.ts`.*/function do_full_update(): void {const rendered_dom = render_tag(new_dom);