From fcf2e607c289e2e040bf80176c211045d5a2aa48 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 30 May 2024 10:07:59 -0700 Subject: [PATCH] rendered_markdown: Fix TypeScript noUncheckedIndexedAccess errors. Signed-off-by: Anders Kaseorg --- web/src/rendered_markdown.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/src/rendered_markdown.ts b/web/src/rendered_markdown.ts index af364d6095..45658b3579 100644 --- a/web/src/rendered_markdown.ts +++ b/web/src/rendered_markdown.ts @@ -296,7 +296,11 @@ export const update_elements = ($content: JQuery): void => { // popover listing the options. let title = $t({defaultMessage: "View in playground"}); const $view_in_playground_button = $buttonContainer.find(".code_external_link"); - if (playground_info && playground_info.length === 1) { + if ( + playground_info && + playground_info.length === 1 && + playground_info[0] !== undefined + ) { title = $t( {defaultMessage: "View in {playground_name}"}, {playground_name: playground_info[0].name}, @@ -327,7 +331,7 @@ export const update_elements = ($content: JQuery): void => { $content .find(".emoji") .text(function () { - const text = $(this).attr("title"); + const text = $(this).attr("title") ?? ""; return ":" + text + ":"; }) .contents()