From e97421874f2716872b10f104a1db05e20d4de680 Mon Sep 17 00:00:00 2001 From: JeelRajodiya Date: Mon, 30 Dec 2024 17:01:01 +0530 Subject: [PATCH] refactor: update type definitions for discussions and improve null handling --- scripts/dashboard/build-dashboard.ts | 6 +++--- types/scripts/dashboard.ts | 10 ++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/dashboard/build-dashboard.ts b/scripts/dashboard/build-dashboard.ts index fa2ef96d437f..80d6c18e06ad 100644 --- a/scripts/dashboard/build-dashboard.ts +++ b/scripts/dashboard/build-dashboard.ts @@ -43,10 +43,10 @@ function getLabel(issue: GoodFirstIssues, filter: string) { async function getDiscussions( query: string, pageSize: number, - endCursor = null -): Promise { + endCursor: null | string = null +): Promise { try { - const result: any = await graphql(query, { + const result: Discussion = await graphql(query, { first: pageSize, after: endCursor, headers: { diff --git a/types/scripts/dashboard.ts b/types/scripts/dashboard.ts index e2fbb12913eb..d71d953fef5a 100644 --- a/types/scripts/dashboard.ts +++ b/types/scripts/dashboard.ts @@ -7,7 +7,7 @@ interface RateLimit { interface PageInfo { hasNextPage: boolean; - endCursor?: string; + endCursor: string | null; } interface Reactions { @@ -138,11 +138,9 @@ export interface HotDiscussionsPullRequestsNode { comments: Comments; } export interface Discussion { - data: { - search: { - pageInfo: PageInfo; - nodes: HotDiscussionsPullRequestsNode[] | HotDiscussionsIssuesNode[] | GoodFirstIssues[]; - }; + search: { + pageInfo: PageInfo; + nodes: HotDiscussionsPullRequestsNode[]; }; rateLimit: RateLimit; }