fix(chapters): narrow optional section fields in page frontmatter

The chapters schema marks section.eyebrow / panelLabel / panelCode /
steps / copy as optional, but pages /agents/, /models/, /skills/
consume them — index access without narrowing failed astro check with
ts(18048). Same for SkillPackageExplorer: aria-selected was String(bool)
which widened to plain string and failed ts(2322) against
ButtonHTMLAttributes.

Fix: guard each required field with a helper that throws a clear
message on missing data, then read .en / .map from the narrowed value.
Page rendering is unchanged — dist/ HTML for all four files is
byte-identical before and after.

No any / as any / ! / @ts-ignore. Schema and tsconfig untouched.
This commit is contained in:
Marcos Paulo
2026-09-05 17:41:38 +00:00
parent 73d1b62989
commit c19e77bcac
4 changed files with 91 additions and 15 deletions
@@ -71,7 +71,7 @@ const packageFiles: PackageFile[] = [
class:list={[{ active: index === 0 }]}
data-skill-file={file.id}
role="tab"
aria-selected={String(index === 0)}
aria-selected={index === 0 ? 'true' : 'false'}
>
<code>{`${file.prefix}${file.label}`}</code>
<small>{file.caption}</small>