From 60bbee49c10bd68a8979be3abab9da75ad20eba8 Mon Sep 17 00:00:00 2001 From: Ed McConnell Date: Sun, 24 Nov 2024 20:47:47 -0500 Subject: [PATCH] Add type for error response --- app/github/GitHubAuth.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/github/GitHubAuth.tsx b/app/github/GitHubAuth.tsx index b07c94716..59992f8d9 100644 --- a/app/github/GitHubAuth.tsx +++ b/app/github/GitHubAuth.tsx @@ -7,6 +7,11 @@ interface GitHubAuthProps { children?: React.ReactNode; } +interface GitHubErrorResponse { + error?: string; + error_description?: string; +} + interface DeviceCodeResponse { device_code: string; user_code: string; @@ -82,7 +87,7 @@ export function GitHubAuth({ onAuthComplete, onError, children }: GitHubAuthProp }); if (!response.ok) { - const errorData = await response.json().catch(() => null); + const errorData = await response.json().catch(() => ({} as GitHubErrorResponse)); throw new Error( errorData?.error || `Failed to start authentication process (${response.status})`