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

Aperta Adatta ai principianti
#829 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
next.js, typescript
Ambito
frontend

Direzione di ricerca

Inizia da src/app/page.tsx, in particolare dalla risoluzione di stats alle righe 93–116 e dalla riga dei contributor nell’hero alla riga 153. Controlla come l’hero e le schede delle statistiche usano il valore risolto, poi esegui npx tsc --noEmit per confermare che il nome non definito è stato corretto. Il lavoro è completato quando la homepage viene compilata e l’hero usa le statistiche risolte; verifica il campo contributor di /analytics/platform prima di presentare quel numero come reale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
1
Fork
94
Merge medio
1h 2m
PR unite (30g)
25

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MergeFi/frontend

Tutte le issue di MergeFi/frontend

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.