Skip to content

Commit 9002925

Browse files
ericyangpanclaude
andcommitted
fix: add type safety checks for indexed access
- Add null checks in RelationshipGraph for NODE_COLORS fallback - Add product existence check in VendorMatrix before rendering - Add section data validation in CollectionScrollbar - Add fallback href in MarkdownContent link rendering - Add pricing tier validation in metadata helpers Fixes type errors from noUncheckedIndexedAccess TypeScript option 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3ac6483 commit 9002925

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

src/app/[locale]/ai-coding-landscape/components/RelationshipGraph.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const EDGE_COLORS: Record<string, string> = {
6969

7070
// Custom node component
7171
function CustomNode({ data }: { data: NodeData }) {
72-
const colors = NODE_COLORS[data.type] || NODE_COLORS.vendor
72+
const colors = (NODE_COLORS[data.type] || NODE_COLORS.vendor)!
7373
const isVendor = data.type === 'vendor'
7474

7575
return (

src/app/[locale]/ai-coding-landscape/components/VendorMatrix.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function MatrixCell({ products, category, categoryColor }: MatrixCellProps) {
5252

5353
if (products.length === 1) {
5454
const product = products[0]
55+
if (!product) return null
5556
return (
5657
<Link
5758
href={product.path}

src/components/CollectionScrollbar.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ export default function CollectionScrollbar() {
2121
const scrollPosition = window.scrollY + 100
2222

2323
for (let i = sections.length - 1; i >= 0; i--) {
24-
const section = document.getElementById(sections[i].id)
24+
const sectionData = sections[i]
25+
if (!sectionData) continue
26+
const section = document.getElementById(sectionData.id)
2527
if (section && section.offsetTop <= scrollPosition) {
26-
setActiveSection(sections[i].id)
28+
setActiveSection(sectionData.id)
2729
break
2830
}
2931
}

src/components/MarkdownContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function renderInlineMarkdown(text: string): React.ReactNode {
106106
parts.push(
107107
<Link
108108
key={key++}
109-
href={match[2]}
109+
href={match[2] || '#'}
110110
className="text-[var(--color-text)] underline hover:no-underline"
111111
>
112112
{match[1]}

src/lib/metadata/helpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ export function formatPriceForDescription(
308308
if (!pricing || pricing.length === 0) return null
309309

310310
const firstTier = pricing[0]
311+
if (!firstTier) return null
311312
if (firstTier.value === null || firstTier.value === 0) {
312313
return 'Free'
313314
}

0 commit comments

Comments
 (0)