From 1776fca011a7c4b3852e544bfa70943c92823648 Mon Sep 17 00:00:00 2001 From: Kevin Lai <70177777+klai95@users.noreply.github.com> Date: Thu, 4 May 2023 02:04:39 -0500 Subject: [PATCH] since it is possible for node.children to be empty, I have updated the code to make node.children optional so no errors occur (#1026) --- frontend/src/components/Markdown/Markdown.utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Markdown/Markdown.utils.ts b/frontend/src/components/Markdown/Markdown.utils.ts index 92286504d..c69166216 100644 --- a/frontend/src/components/Markdown/Markdown.utils.ts +++ b/frontend/src/components/Markdown/Markdown.utils.ts @@ -58,7 +58,7 @@ export function getHeadersFromMarkdown(markdown: string): TOCHeader[] { // Convert all H2 headings into TOCHeader objects. return children .filter((node): node is HeadingNode => node.tagName === TOC_HEADER_TAG) - .filter((node) => node.children[0].value !== undefined) + .filter((node) => node.children[0]?.value !== undefined) .map((node) => ({ id: node.properties.id, text: node.children[0].value,