Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

fix: don't echo unknown region codes as their name in the by-region table

Aperta Adatta ai principianti
#46 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
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
frontend

Direzione di ricerca

Inizia da countryName in lib/utils.ts, dove Intl.DisplayNames viene creato senza l'opzione fallback, e da REGION_ALIASES in blocks/charts/region-map.tsx. Imposta fallback: "none" in modo che i codici sconosciuti come EL e XX non mostrino alcun nome, e sposta la mappa degli alias in lib/regions.ts così la tabella può cercare il paese associato. Il lavoro è completato quando una fixture che dichiara EL, XX e UK mostra "greece", nessun nome e "united kingdom", e pnpm typecheck e pnpm lint passano. La issue dipende da #45, quindi controlla prima se quella modifica è già stata unita.

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

Descrizione

bug good first issue

Spotted while building the world map (#45).

Problem

The by-region table shows each code's country name next to it, via countryName (lib/utils.ts after #45, before that in blocks/by-region.tsx). Intl.DisplayNames defaults to fallback: "code", so for a code it doesn't know it returns the code itself, which we lowercase:

declared shown
EL EL el
XX XX xx
UK UK united kingdom (Intl knows this one)

EL is the EU's code for Greece, and the map (#45) already draws it on GR through REGION_ALIASES, so the table and the map disagree.

Solution

  1. In countryName, pass fallback: "none" to Intl.DisplayNames. It then returns undefined for an unknown code, so the existing ?? "" shows no name:
    const regionNames = new Intl.DisplayNames(["en"], {
      type: "region",
      fallback: "none",
    })
    
    Checked in Node: EL/XX → undefined, UK/GB → "United Kingdom", GR → "Greece".
  2. Name an aliased code after the country the map draws it on. Move REGION_ALIASES from blocks/charts/region-map.tsx to lib/regions.ts, and have the table look up countryName(REGION_ALIASES[code] ?? code), so EL reads "greece". The code column still shows what was declared.

Out of scope: rewriting declared codes in the indexer (regionCode in worker/src/stats.ts), which would split history between the old and new code.

Verify

pnpm typecheck && pnpm lint, then with a local fixture (see CLAUDE.md) that declares EL, XX and UK, check that the table shows "greece", no name, and "united kingdom".

🤖 Generated with Claude Code

Lingua principale
TypeScript
Stelle
2
Fork
0
Merge medio
6h 50m
PR unite (30g)
47

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 decdn/stats

Tutte le issue di decdn/stats

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.