Homepage fails to compile: the hero's contributor count references an undefined `platformStats`, and would show the mock value even once it resolves

Open Beginner friendly
#829 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
next.js, typescript
Domain
frontend

Research direction

Start with src/app/page.tsx, especially the stats resolution at lines 93–116 and the hero contributor line at line 153. Check how the hero and stat cards use the resolved value, then run npx tsc --noEmit to confirm the undefined name is fixed. Done when the homepage compiles and the hero reads from the resolved stats; verify the /analytics/platform contributor field before presenting that number as real.

Written by the indexing model from the issue text.

Description

bug

Location

src/app/page.tsx:153 (import at line 23, live value at lines 93-116)

Problem

The hero's social-proof line reads:

{formatInteger(platformStats.activeContributors)} contributors

There is no binding named platformStats in this module. Line 23 deliberately renames the import:

import {
  platformStats as mockPlatformStats,
  ...
} from "@/lib/mock-data";

platformStats is not declared locally, not a global, and not imported under that name anywhere in the file — grep -n platformStats src/app/page.tsx returns exactly two hits: the aliased import on line 23 and this usage on line 153. The result is TS2304: Cannot find name 'platformStats', so tsc --noEmit and next build both fail, and at runtime the expression would throw a ReferenceError while rendering the homepage.

There is a second defect hiding behind the first. The component resolves a live figure into a local stats (lines 93-116: it fetches /analytics/platform with next: { revalidate: 60 } and falls back to mockPlatformStats), and every StatCard below reads from stats. Only this one line bypasses it. So the minimal "fix the name" change — rewriting it to mockPlatformStats.activeContributors — would compile but permanently print the bundled mock contributor count in the hero while the stat grid twenty lines down prints the real one, which is the exact failure closed issue #237 was about ("HomePage's hero copy hardcodes '341 contributors' as literal text instead of referencing platformStats").

Note also that DataSourceNotice (line 189) only covers the stat grid, so a mock-sourced hero number would carry no provenance badge at all.

Why it matters

/ is the application's entry point and the highest-priority URL in the sitemap (src/lib/sitemap.ts:46 gives it priority: 1). A TS2304 here means the whole build is red, so nothing ships. If it is patched to the mock constant instead of the live one, the landing page tells every visitor a fabricated number of contributors — a trust-relevant claim on a product that moves real money — and contradicts the live "Active contributors" card rendered on the same screen.

Reproduction

  1. npm ci
  2. npx tsc --noEmit → src/app/page.tsx(153,30): error TS2304: Cannot find name 'platformStats'.
  3. npm run build fails with the same error. Under npm run dev, loading / renders the Next.js error overlay instead of the homepage.

Suggested fix

Change line 153 to read from the resolved local, so the hero and the stat grid can never disagree:

{formatInteger(stats.activeContributors)} contributors

Two follow-ups worth doing in the same change:

  • The live mapping at lines 106-111 assigns activeContributors: raw.totalRepos. A repository count is not a contributor count; either the backend field name is wrong or the mapping is. Confirm against the /analytics/platform response before relying on this number in hero copy.
  • Move the statsSource === "mock" provenance notice (line 189) above the hero's social-proof line, or add a SampleDataChip beside it, so a fallback hero number is visibly marked as sample data.

Adding tsc --noEmit to CI would prevent an undefined identifier in a route file from reaching the default branch.

Dominant language
TypeScript
Stars
1
Forks
94
Avg merge
1h 2m
Merged PRs (30d)
25

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MergeFi/frontend

All issues in MergeFi/frontend

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.