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

[Schema Inaccuracy] GET /repos/{owner}/{repo}/issues/{issue_number}/timeline" events union is not discriminating

Aperta
#5,801 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
openapi, typescript
Ambito
api

Direzione di ricerca

Inizia dallo schema OpenAPI per GET /repos/{owner}/{repo}/issues/{issue_number}/timeline e verifica come è definita l’unione delle risposte degli eventi. Controlla come è rappresentato il campo event tra le varianti, quindi verifica che i valori di event discriminino il payload, in modo che timelineEvent.created_at sia disponibile per gli eventi di merge.

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

Descrizione

feature
What happened?

const timelinePages = octokit.paginate.iterator(
  octokit.issues.listEventsForTimeline,
  { repo, owner, issue_number },
);

(async function () {
  for await (const page of timelinePages) {
    for (const timelineEvent of page.data) {
      if (timelineEvent.event === "merged") timelineEvent.created_at;
    }
  }
})().catch((e) => console.log(e));


gives an error

Property 'created_at' does not exist on type '{ id: number; node_id: string; url: string; actor: { name?: string | null | undefined; email?: string | null | undefined; login: string; id: number; node_id: string; avatar_url: string; gravatar_id: string | null; ... 14 more ...; user_view_type?: string | undefined; }; ... 5 more ...; label: { ...; }; } | ... 20 mo...'.
Property 'created_at' does not exist on type '{ event?: string | undefined; sha: string; node_id: string; url: string; author: { date: string; email: string; name: string; }; committer: { date: string; email: string; name: string; }; message: string; tree: { ...; }; parents: { ...; }[]; verification: { ...; }; html_url: string; }'. (ts 2339)

because TypeScript doesn't seem to have a way to discriminate the values in the union of event types.

It's basically impossible to inspect any of the event payload in a typed way due to this union being overlapping.

I think the fix would be to use the event field as a discriminator.

Versions

Octokit 22.0

Relevant log output

Code of Conduct
  • I agree to follow this project's Code of Conduct

The told me to reopen this issue here: https://github.com/octokit/types.ts/issues/676#issuecomment-3135915038

Lingua principale
Nessun dato sulla lingua
Stelle
1.6k
Fork
342
Merge medio
2h 23m
PR unite (30g)
57

Guida per i contributori

Apri la guida per i contributori

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 github/rest-api-description

Tutte le issue di github/rest-api-description

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.