From 2598596ad26934177a16e78245df3a41d409b442 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 20 Feb 2024 15:36:12 -0800 Subject: [PATCH] vdom: Eliminate undefined type declaration for impossible case. This was just debugging logic working around the fact that vdom.ts was not originally implemented in TypeScript, and should not be polluting our types. --- web/src/pm_list.ts | 4 ++-- web/src/topic_list.ts | 3 +-- web/src/vdom.ts | 9 ++------- web/tests/vdom.test.js | 3 --- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/web/src/pm_list.ts b/web/src/pm_list.ts index a49eac2aa3..7ee1bd6798 100644 --- a/web/src/pm_list.ts +++ b/web/src/pm_list.ts @@ -63,8 +63,8 @@ export function _build_direct_messages_list(): vdom.Tag { function set_dom_to(new_dom: vdom.Tag): void { const $container = scroll_util.get_content_element($("#direct-messages-list")); - function replace_content(html: string | undefined): void { - $container.html(html!); + function replace_content(html: string): void { + $container.html(html); } function find(): JQuery { diff --git a/web/src/topic_list.ts b/web/src/topic_list.ts index 684e4caf01..03197f5165 100644 --- a/web/src/topic_list.ts +++ b/web/src/topic_list.ts @@ -206,8 +206,7 @@ export class TopicListWidget { build(spinner = false): void { const new_dom = this.build_list(spinner); - const replace_content = (html?: string): void => { - assert(html !== undefined); + const replace_content = (html: string): void => { this.remove(); this.$parent_elem.append(html); }; diff --git a/web/src/vdom.ts b/web/src/vdom.ts index 412373b954..10058506b3 100644 --- a/web/src/vdom.ts +++ b/web/src/vdom.ts @@ -47,7 +47,7 @@ export function ul(opts: Options): Tag { }; } -export function render_tag(tag: Tag): string | undefined { +export function render_tag(tag: Tag): string { /* This renders a tag into a string. It will automatically escape attributes, but it's your @@ -66,11 +66,6 @@ export function render_tag(tag: Tag): string | undefined { const start_tag = "<" + tag_name + attr_str + ">"; const end_tag = ""; - if (opts.keyed_nodes === undefined) { - blueslip.error("We need keyed_nodes to render innards."); - return undefined; - } - const innards = opts.keyed_nodes.map((node) => node.render()).join("\n"); return start_tag + "\n" + innards + "\n" + end_tag; } @@ -97,7 +92,7 @@ export function update_attrs( } export function update( - replace_content: (html: string | undefined) => void, + replace_content: (html: string) => void, find: () => JQuery, new_dom: Tag, old_dom: Tag | undefined, diff --git a/web/tests/vdom.test.js b/web/tests/vdom.test.js index 98391df1d0..5d6e4c9f31 100644 --- a/web/tests/vdom.test.js +++ b/web/tests/vdom.test.js @@ -249,7 +249,4 @@ run_test("error checking", () => { const ul = {opts: {attrs: []}}; vdom.update(replace_content, find, ul, ul); - - blueslip.expect("error", "We need keyed_nodes to render innards."); - vdom.render_tag(ul); });