Skip to content

Commit

Permalink
Add type for error response
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed McConnell committed Nov 25, 2024
1 parent 0c1b5c0 commit 60bbee4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/github/GitHubAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ interface GitHubAuthProps {
children?: React.ReactNode;
}

interface GitHubErrorResponse {
error?: string;
error_description?: string;
}

interface DeviceCodeResponse {
device_code: string;
user_code: string;
Expand Down Expand Up @@ -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 ||

Check failure on line 92 in app/github/GitHubAuth.tsx

View workflow job for this annotation

GitHub Actions / Test

Property 'error' does not exist on type '{}'.
`Failed to start authentication process (${response.status})`
Expand Down

0 comments on commit 60bbee4

Please sign in to comment.