Why It Matters
- Catch broken links during development (TypeScript errors)
- Visual feedback in browser (red underline)
- Maintain documentation quality as your API evolves
- Build confidence in your docs
Two Validation Layers
Compile-Time (TypeScript)
TypeScript validates link targets before build:Runtime (Set Membership)
Browser checks if targets exist in auto-generated Sets:Auto-Generated Files
Runningmint-tsdocs generate creates three validation file pairs:
ValidRefs (API References)
ValidRefs.jsx
ValidRefs.d.ts
docs/snippets/tsdocs/ValidRefs.*
ValidPages (Documentation)
ValidPages.jsx
ValidPages.d.ts
docs/snippets/tsdocs/ValidPages.*
Validation Flow
1
Write link in MDX
2
TypeScript validates (edit time)
IDE checks target against type definitions, shows errors immediately
3
Component renders (runtime)
Browser checks Set membership:
VALID_REFS.has(target)4
Visual feedback
- Valid: normal link
- Invalid: red underline + “broken-link” CSS class
Broken Link Styling
Default CSS (customizable viadocs/style.css):
- Red color:
#ef4444(light mode),#f87171(dark mode) - Red dotted underline: 2px
- Red wavy text decoration
- Tooltip: “Broken API reference: ” or “Broken page link: ”
When Links Break
| Component | Common Causes |
|---|---|
| RefLink | API item renamed, deleted, not exported, typo in RefId |
| PageLink | Page removed from docs.json, renamed, moved, typo in path |
Fixing Broken Links
- RefLink
- PageLink
- Check TypeScript error
- Find correct RefId in API reference
- Update target prop
- Run
mint-tsdocs generateif source changed
Performance
The validation system is designed for minimal impact: Compile-time: Zero runtime cost, instant IDE feedback Runtime: O(1) Set lookups, small payload (few KB), no network requestsTroubleshooting
Validation files not found
Validation files not found
Run
mint-tsdocs generate to create files in docs/snippets/tsdocs/TypeScript not detecting errors
TypeScript not detecting errors
- Check
.d.tsfiles exist - Restart TypeScript server (VS Code: Cmd+Shift+P → “Restart TS Server”)
- Verify
tsconfig.jsonincludes snippets folder
All links showing broken
All links showing broken
- Check browser console for import errors
- Clear cache and hard refresh
- Run
mint-tsdocs generateto sync validation files
Best Practices
Run
mint-tsdocs generate after API or navigation changesEnable TypeScript in MDX for compile-time validation
Test locally with
mint dev before publishingFix broken links before committing

