From 75f6a9a3435853b532029b9bba921c055111c9d0 Mon Sep 17 00:00:00 2001 From: Jimmy Royer Date: Tue, 10 Sep 2024 16:03:10 -0400 Subject: [PATCH] Made some type annotations narrower. --- src/exportComments.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/exportComments.ts b/src/exportComments.ts index 2b98043..2ca5354 100644 --- a/src/exportComments.ts +++ b/src/exportComments.ts @@ -31,7 +31,7 @@ const argv = yargs(hideBin(process.argv)) alias: "t", type: "string", description: "GitHub personal access token", - demandOption: true, + demandOption: false, default: process.env.GITHUB_TOKEN, }) .option("owner", { @@ -79,7 +79,7 @@ const csvWriter = createObjectCsvWriter({ ], }); -const reactionToCategory: { [key: string]: string } = { +const reactionToCategory: Record = { "+1": "Useful", eyes: "Noisy", confused: "Hallucination", @@ -87,7 +87,7 @@ const reactionToCategory: { [key: string]: string } = { "-1": "Incorrect", }; -function extractCategories(reactions: any): string[] { +function extractCategories(reactions: Record): string[] { return Object.keys(reactions) .filter( (reaction) => reactionToCategory[reaction] && reactions[reaction] > 0 @@ -122,7 +122,7 @@ async function fetchCommentsForPR(prNumber: number): Promise { ); let comments: Comment[] = await Promise.all( - response.data.map(async (comment: any) => { + response.data.map(async (comment: Record) => { const categories = extractCategories(comment.reactions); return { author: comment.user.login,