diff --git a/tools/test-js-with-node b/tools/test-js-with-node index 13f7160b52..ac058643d6 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -72,7 +72,7 @@ EXEMPT_FILES = make_set( "web/src/compose_closed_ui.ts", "web/src/compose_fade.ts", "web/src/compose_notifications.ts", - "web/src/compose_popovers.js", + "web/src/compose_popovers.ts", "web/src/compose_recipient.ts", "web/src/compose_reply.ts", "web/src/compose_send_menu_popover.js", diff --git a/web/src/compose_popovers.js b/web/src/compose_popovers.ts similarity index 95% rename from web/src/compose_popovers.js rename to web/src/compose_popovers.ts index 11279829c5..9d0c8c9351 100644 --- a/web/src/compose_popovers.js +++ b/web/src/compose_popovers.ts @@ -1,4 +1,5 @@ import $ from "jquery"; +import assert from "minimalistic-assert"; import * as tippy from "tippy.js"; import render_compose_control_buttons_popover from "../templates/popovers/compose_control_buttons/compose_control_buttons_popover.hbs"; @@ -11,7 +12,7 @@ import * as popovers from "./popovers"; import * as rows from "./rows"; import {parse_html} from "./ui_util"; -export function initialize() { +export function initialize(): void { // compose box buttons popover shown on mobile widths. // We want this click event to propagate and hide other popovers // that could possibly obstruct user from using this popover. @@ -52,7 +53,7 @@ export function initialize() { // Destroy instance so that event handlers // are destroyed too. instance.destroy(); - popover_menus.popover_instances.compose_mobile_button = undefined; + popover_menus.popover_instances.compose_mobile_button = null; }, }); @@ -62,6 +63,7 @@ export function initialize() { popover_menus.register_popover_menu(".compose_control_menu_wrapper", { placement: "top", onShow(instance) { + assert(instance.reference instanceof HTMLElement); const parent_row = rows.get_closest_row(instance.reference); let preview_mode_on; // If the popover is opened from a message edit form, we want to @@ -85,7 +87,7 @@ export function initialize() { }, onHidden(instance) { instance.destroy(); - popover_menus.popover_instances.compose_control_buttons = undefined; + popover_menus.popover_instances.compose_control_buttons = null; }, }); }