ts: Convert `stream_settings_containers.js` to TypeScript.

Added assertion to enforce `sub` is not `undefined` and thus type
safe for the rest.
Added type annotation to function parameter and return value.
This commit is contained in:
AcKindle3 2023-06-08 18:48:46 -04:00 committed by Tim Abbott
parent 54395612c7
commit 1aeab40779
3 changed files with 14 additions and 10 deletions

View File

@ -194,7 +194,7 @@ EXEMPT_FILES = make_set(
"web/src/stream_list.js",
"web/src/stream_muting.js",
"web/src/stream_popover.js",
"web/src/stream_settings_containers.js",
"web/src/stream_settings_containers.ts",
"web/src/stream_settings_ui.js",
"web/src/stream_ui_updates.js",
"web/src/submessage.js",

View File

@ -1,9 +0,0 @@
import $ from "jquery";
export function get_edit_container(sub) {
return $(
`#subscription_overlay .subscription_settings[data-stream-id='${CSS.escape(
sub.stream_id,
)}']`,
);
}

View File

@ -0,0 +1,13 @@
import $ from "jquery";
import assert from "minimalistic-assert";
import type {StreamSubscription} from "./sub_store";
export function get_edit_container(sub: StreamSubscription): JQuery {
assert(sub !== undefined, "Stream subscription is undefined.");
return $(
`#subscription_overlay .subscription_settings[data-stream-id='${CSS.escape(
sub.stream_id.toString(),
)}']`,
);
}