From e39b56fc5de5a8791bdf8fa85b8366de213804a9 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Mon, 23 Nov 2026 19:15:02 -0500 Subject: [PATCH] fix(tests): narrow markdown-it attributes to strings in doc link checks (#14217) Token.attrGet returns string | number | null, so the link checks added in #14207 failed typecheck on main. Keep only string href values before matching them. --- tests/boundary/cli/githubActionsExample.test.ts | 7 ++++--- tests/conformance/readmeConsistency.test.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/boundary/cli/githubActionsExample.test.ts b/tests/boundary/cli/githubActionsExample.test.ts index c6d7067f05..9c1e604053 100644 --- a/tests/boundary/cli/githubActionsExample.test.ts +++ b/tests/boundary/cli/githubActionsExample.test.ts @@ -110,9 +110,10 @@ it("links to the workflow asset outside the documentation site's base", async () const workflowLinks = new MarkdownIt() .parse(guide, {}) .flatMap((token) => token.children ?? []) - .flatMap((token) => - token.type === "link_open" ? [token.attrGet("href") ?? ""] : [], - ) + .flatMap((token) => { + const href = token.type === "link_open" ? token.attrGet("href") : null; + return typeof href === "string" ? [href] : []; + }) .filter((href) => href.endsWith("examples/github-actions/rea-analysis.yml"), ); diff --git a/tests/conformance/readmeConsistency.test.ts b/tests/conformance/readmeConsistency.test.ts index deebdaca6a..6552ec3a56 100644 --- a/tests/conformance/readmeConsistency.test.ts +++ b/tests/conformance/readmeConsistency.test.ts @@ -98,7 +98,7 @@ describe("onboarding documentation product facts", () => { for (const child of token.children ?? []) { const href = child.type === "link_open" ? child.attrGet("href") : null; - if (href?.startsWith("#")) + if (typeof href === "string" && href.startsWith("#")) fragments.push(decodeURIComponent(href.slice(1))); } }