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.

vdom: Eliminate undefined type declaration for impossible case.

Tim Abbott2598596ad269
diff --git a/web/src/pm_list.ts b/web/src/pm_list.ts
index a49eac2aa32..7ee1bd6798b 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<PMNode> {
function set_dom_to(new_dom: vdom.Tag<PMNode>): 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 684e4caf013..03197f5165f 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 412373b954e..10058506b3c 100644
--- a/web/src/vdom.ts
+++ b/web/src/vdom.ts
@@ -47,7 +47,7 @@ export function ul<T>(opts: Options<T>): Tag<T> {
};
}
-export function render_tag<T>(tag: Tag<T>): string | undefined {
+export function render_tag<T>(tag: Tag<T>): 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<T>(tag: Tag<T>): string | undefined {
const start_tag = "<" + tag_name + attr_str + ">";
const end_tag = "</" + tag_name + ">";
- 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<T>(
- replace_content: (html: string | undefined) => void,
+ replace_content: (html: string) => void,
find: () => JQuery,
new_dom: Tag<T>,
old_dom: Tag<T> | undefined,
diff --git a/web/tests/vdom.test.js b/web/tests/vdom.test.js
index 98391df1d09..5d6e4c9f31d 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);
});