[Schema Inaccuracy] GET /repos/{owner}/{repo}/issues/{issue_number}/timeline" events union is not discriminating
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
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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di github/rest-api-description
-
feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
github/rest-api-description#7220 ·
-
feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
github/rest-api-description#7201 ·
-
feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
github/rest-api-description#7163 ·
-
Runner deprecations: registration_deprecates_at is declared on the response but never returned Apertafeature
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
github/rest-api-description#7162 ·
-
feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
github/rest-api-description#7135 ·
Tutte le issue di github/rest-api-description
Issue simili
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
canonical/paas-charm#368 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
tech debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
area:workflow bug ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
fil-donadoni/tolaria#4409 ·
-
status/awaiting_triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100