web: Condense unnecessarily verbose function signatures.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-07-31 12:43:41 -07:00
committed by Tim Abbott
parent 6b8fc6de36
commit d074848673
6 changed files with 8 additions and 13 deletions

View File

@@ -70,7 +70,7 @@ export function generate_and_insert_audio_or_video_call_link(
is_video_call: !is_audio_call, is_video_call: !is_audio_call,
}; };
const make_zoom_call: () => void = () => { const make_zoom_call = (): void => {
const xhr = channel.post({ const xhr = channel.post({
url: "/json/calls/zoom/create", url: "/json/calls/zoom/create",
data: request, data: request,

View File

@@ -24,13 +24,12 @@ import {user_settings} from "./user_settings";
export let toggler: Toggle | undefined; export let toggler: Toggle | undefined;
function format_usage_html(...keys: string[]): string { function format_usage_html(...keys: string[]): string {
const get_formatted_keys: () => string = () => keys.map((key) => `<kbd>${key}</kbd>`).join("+");
return $t_html( return $t_html(
{ {
defaultMessage: "(or <key-html></key-html>)", defaultMessage: "(or <key-html></key-html>)",
}, },
{ {
"key-html": get_formatted_keys, "key-html": () => keys.map((key) => `<kbd>${key}</kbd>`).join("+"),
}, },
); );
} }

View File

@@ -424,8 +424,7 @@ export function show_from_selected_message(): void {
const $message_selected = $(".selected_message"); const $message_selected = $(".selected_message");
let $message = $message_selected; let $message = $message_selected;
// This is a function to satisfy eslint unicorn/no-array-callback-reference // This is a function to satisfy eslint unicorn/no-array-callback-reference
const media_classes: () => string = () => const media_classes = (): string => ".message_inline_image img, .message_inline_image video";
".message_inline_image img, .message_inline_image video";
let $media = $message.find<HTMLMediaElement>(media_classes()); let $media = $message.find<HTMLMediaElement>(media_classes());
let $prev_traverse = false; let $prev_traverse = false;

View File

@@ -25,10 +25,7 @@ import * as unread_ops from "./unread_ops";
import * as unread_ui from "./unread_ui"; import * as unread_ui from "./unread_ui";
import * as util from "./util"; import * as util from "./util";
const show_step: ($process: JQuery, step: number) => void = function ( const show_step = function ($process: JQuery, step: number): void {
$process: JQuery,
step: number,
) {
$process $process
.find("[data-step]") .find("[data-step]")
.hide() .hide()

View File

@@ -53,7 +53,7 @@ export function path_parts(): string[] {
return window.location.pathname.split("/").filter((chunk) => chunk !== ""); return window.location.pathname.split("/").filter((chunk) => chunk !== "");
} }
const apps_events: () => void = function () { const apps_events = function (): void {
const info: Record<UserOS, VersionInfo> = { const info: Record<UserOS, VersionInfo> = {
windows: { windows: {
alt: "Windows", alt: "Windows",
@@ -168,7 +168,7 @@ const apps_events: () => void = function () {
update_page(); update_page();
}; };
const events: () => void = function () { const events = function (): void {
if (path_parts().includes("apps")) { if (path_parts().includes("apps")) {
apps_events(); apps_events();
} }
@@ -291,7 +291,7 @@ $(document).on("click", ".comparison-tab", function (this: HTMLElement) {
// on subheaders of interest (those about to be sticky) // on subheaders of interest (those about to be sticky)
let previous_entry_y = 0; let previous_entry_y = 0;
const isScrollingUp: () => boolean = () => { const isScrollingUp = (): boolean => {
let is_scrolling_up = true; let is_scrolling_up = true;
if (window.scrollY > previous_y_position) { if (window.scrollY > previous_y_position) {
is_scrolling_up = false; is_scrolling_up = false;

View File

@@ -556,7 +556,7 @@ function open_edit_form_modal(this: HTMLElement): void {
} }
if (Object.keys(deleted_values).length !== 0) { if (Object.keys(deleted_values).length !== 0) {
const edit_select_field_modal_callback: () => void = () => { const edit_select_field_modal_callback = (): void => {
show_modal_for_deleting_options(field, deleted_values, update_profile_field); show_modal_for_deleting_options(field, deleted_values, update_profile_field);
}; };
dialog_widget.close(edit_select_field_modal_callback); dialog_widget.close(edit_select_field_modal_callback);