diff --git a/web/src/debug.ts b/web/src/debug.ts index 8854eff4fe..1b933b54ce 100644 --- a/web/src/debug.ts +++ b/web/src/debug.ts @@ -101,7 +101,7 @@ export class IterationProfiler { if (diff > 1) { this.sections.set( "_rest_of_iteration", - (this.sections.get("_rest_of_iteration") || 0) + diff, + (this.sections.get("_rest_of_iteration") ?? 0) + diff, ); } this.last_time = now; @@ -109,7 +109,7 @@ export class IterationProfiler { section(label: string): void { const now = window.performance.now(); - this.sections.set(label, (this.sections.get(label) || 0) + (now - this.last_time)); + this.sections.set(label, (this.sections.get(label) ?? 0) + (now - this.last_time)); this.last_time = now; } diff --git a/web/src/dialog_widget.ts b/web/src/dialog_widget.ts index ec708b30bc..c6a453b6cf 100644 --- a/web/src/dialog_widget.ts +++ b/web/src/dialog_widget.ts @@ -121,7 +121,7 @@ export function launch(conf: WidgetConfig): void { // * loading_spinner: Whether to show a loading spinner inside the // submit button when clicked. - const html_submit_button = conf.html_submit_button || $t_html({defaultMessage: "Save changes"}); + const html_submit_button = conf.html_submit_button ?? $t_html({defaultMessage: "Save changes"}); const html = render_dialog_widget({ heading_text: conf.html_heading, link: conf.help_link, diff --git a/web/src/emoji.ts b/web/src/emoji.ts index 52d34a7349..b7edf895cf 100644 --- a/web/src/emoji.ts +++ b/web/src/emoji.ts @@ -204,7 +204,7 @@ function build_emojis_by_name({ const emoji_dict: EmojiDict = { name: emoji_name, display_name: emoji_name, - aliases: default_emoji_aliases.get(codepoint) || [], + aliases: default_emoji_aliases.get(codepoint) ?? [], is_realm_emoji: false, emoji_code: codepoint, has_reacted: false, diff --git a/web/src/keydown_util.ts b/web/src/keydown_util.ts index aa032773be..310728c644 100644 --- a/web/src/keydown_util.ts +++ b/web/src/keydown_util.ts @@ -37,6 +37,6 @@ export function is_enter_event(event: JQuery.KeyDownEvent): boolean { // phonetic input method like ZhuYin in a character-based // language. See #22062 for details. Further reading: // https://developer.mozilla.org/en-US/docs/Glossary/Input_method_editor - const isComposing: boolean = event.originalEvent?.isComposing || false; + const isComposing = event.originalEvent?.isComposing ?? false; return !isComposing && event.key === "Enter"; } diff --git a/web/src/overlays.ts b/web/src/overlays.ts index 6daf4de06e..4625024a0e 100644 --- a/web/src/overlays.ts +++ b/web/src/overlays.ts @@ -110,7 +110,7 @@ export function open_overlay(opts: OverlayOptions): void { if (active_overlay || open_overlay_name) { blueslip.error( `Programming error - trying to open ${opts.name} before closing ${ - open_overlay_name || "undefined" + open_overlay_name ?? "undefined" }`, ); @@ -255,7 +255,7 @@ export function close_overlay(name: string): void { call_hooks(pre_close_hooks); if (name !== open_overlay_name) { - blueslip.error(`Trying to close ${name} when ${open_overlay_name || "undefined"} is open.`); + blueslip.error(`Trying to close ${name} when ${open_overlay_name ?? "undefined"} is open.`); return; } @@ -304,7 +304,7 @@ export function close_modal(modal_id: string, conf: Pick { // In case user presses `back` with menu open. // See https://github.com/zulip/zulip/pull/24301#issuecomment-1418547337. if ($(".top-menu-tab-input:checked").length === 1) { - const sub_menu_height = $(".top-menu-tab-input:checked ~ .top-menu-submenu").height() || 0; + const sub_menu_height = $(".top-menu-tab-input:checked ~ .top-menu-submenu").height() ?? 0; $("#top-menu-submenu-backdrop").css("height", sub_menu_height + 16); } diff --git a/web/src/portico/team.ts b/web/src/portico/team.ts index 3580f931a1..d05c2e2f08 100644 --- a/web/src/portico/team.ts +++ b/web/src/portico/team.ts @@ -48,7 +48,7 @@ const loaded_repos: string[] = []; function calculate_total_commits(contributor: Contributor): number { let commits = 0; for (const repo_name of all_repository_names) { - commits += contributor[repo_name] || 0; + commits += contributor[repo_name] ?? 0; } return commits; } @@ -132,11 +132,11 @@ export default function render_tabs(contributors: Contributor[]): void { $(`#${CSS.escape(tab_name)}`).on("click", () => { if (!loaded_repos.includes(repo_name)) { - const filtered_by_repo = contributors_list.filter((c) => c[repo_name] || 0); + const filtered_by_repo = contributors_list.filter((c) => c[repo_name] ?? 0); const html = filtered_by_repo .sort((a, b) => { - const a_commits = a[repo_name] || 0; - const b_commits = b[repo_name] || 0; + const a_commits = a[repo_name] ?? 0; + const b_commits = b[repo_name] ?? 0; return a_commits < b_commits ? 1 : a_commits > b_commits ? -1 : 0; }) .map((c) => @@ -153,7 +153,7 @@ export default function render_tabs(contributors: Contributor[]): void { $(`#tab-${CSS.escape(tab_name)} .contributors-grid`).html(html); const contributor_count = filtered_by_repo.length; const hundred_plus_contributor_count = filtered_by_repo.filter((c) => { - const commits = c[repo_name] || 0; + const commits = c[repo_name] ?? 0; return commits >= 100; }).length; const repo_url = `https://github.com/zulip/${repo_name}`; diff --git a/web/src/sentry.ts b/web/src/sentry.ts index 6009a34195..8b46f33565 100644 --- a/web/src/sentry.ts +++ b/web/src/sentry.ts @@ -46,7 +46,7 @@ if (page_params.server_sentry_dsn) { Sentry.init({ dsn: page_params.server_sentry_dsn, - environment: page_params.server_sentry_environment || "development", + environment: page_params.server_sentry_environment ?? "development", tunnel: "/error_tracing", release: "zulip-server@" + ZULIP_VERSION, @@ -56,8 +56,8 @@ if (page_params.server_sentry_dsn) { }), ], allowUrls: url_matches, - sampleRate: page_params.server_sentry_sample_rate || 0, - tracesSampleRate: page_params.server_sentry_trace_rate || 0, + sampleRate: page_params.server_sentry_sample_rate ?? 0, + tracesSampleRate: page_params.server_sentry_trace_rate ?? 0, initialScope: { tags: { realm: sentry_key, diff --git a/web/src/spoilers.ts b/web/src/spoilers.ts index dbce690aa3..081ee51d86 100644 --- a/web/src/spoilers.ts +++ b/web/src/spoilers.ts @@ -1,7 +1,7 @@ import $ from "jquery"; function collapse_spoiler($spoiler: JQuery): void { - const spoiler_height = $spoiler.height() || 0; + const spoiler_height = $spoiler.height() ?? 0; // Set height to rendered height on next frame, then to zero on following // frame to allow CSS transition animation to work diff --git a/web/src/typing_data.ts b/web/src/typing_data.ts index 7048a9d0bb..3ad98fb591 100644 --- a/web/src/typing_data.ts +++ b/web/src/typing_data.ts @@ -18,7 +18,7 @@ function get_key(group: number[]): string { export function add_typist(group: number[], typist: number): void { const key = get_key(group); - const current = typist_dct.get(key) || []; + const current = typist_dct.get(key) ?? []; if (!current.includes(typist)) { current.push(typist); } @@ -27,7 +27,7 @@ export function add_typist(group: number[], typist: number): void { export function remove_typist(group: number[], typist: number): boolean { const key = get_key(group); - let current = typist_dct.get(key) || []; + let current = typist_dct.get(key) ?? []; if (!current.includes(typist)) { return false; @@ -41,7 +41,7 @@ export function remove_typist(group: number[], typist: number): boolean { export function get_group_typists(group: number[]): number[] { const key = get_key(group); - const user_ids = typist_dct.get(key) || []; + const user_ids = typist_dct.get(key) ?? []; return muted_users.filter_muted_user_ids(user_ids); } diff --git a/web/webpack.config.ts b/web/webpack.config.ts index ff167c85a3..e8d54393f3 100644 --- a/web/webpack.config.ts +++ b/web/webpack.config.ts @@ -198,7 +198,7 @@ export default ( }, plugins: [ new DefinePlugin({ - ZULIP_VERSION: JSON.stringify(env.ZULIP_VERSION || "development"), + ZULIP_VERSION: JSON.stringify(env.ZULIP_VERSION ?? "development"), }), new DebugRequirePlugin(), new BundleTracker({