Refactor: Update type safety status

This commit is contained in:
gpt-engineer-app[bot]
2025-10-21 17:19:19 +00:00
parent 81fccdc4d0
commit e580f1f4b4
21 changed files with 55 additions and 49 deletions

View File

@@ -26,7 +26,7 @@ export function AuthButtons() {
description: "You've been signed out successfully."
});
navigate('/');
} catch (error) {
} catch (error: unknown) {
const errorMsg = getErrorMessage(error);
toast({
variant: "destructive",

View File

@@ -26,7 +26,7 @@ export function MFAChallenge({ factorId, onSuccess, onCancel }: MFAChallengeProp
const { data, error } = await supabase.auth.mfa.challenge({ factorId });
if (error) throw error;
setChallengeId(data.id);
} catch (error) {
} catch (error: unknown) {
toast({
variant: "destructive",
title: "MFA Challenge Failed",
@@ -59,7 +59,7 @@ export function MFAChallenge({ factorId, onSuccess, onCancel }: MFAChallengeProp
});
onSuccess();
}
} catch (error) {
} catch (error: unknown) {
toast({
variant: "destructive",
title: "Verification Failed",

View File

@@ -50,7 +50,7 @@ export function TOTPSetup() {
updated_at: factor.updated_at
}));
setFactors(totpFactors);
} catch (error) {
} catch (error: unknown) {
logger.error('Failed to fetch TOTP factors', {
userId: user?.id,
action: 'fetch_totp_factors',

View File

@@ -128,7 +128,7 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
if (saved) {
return JSON.parse(saved);
}
} catch (error) {
} catch (error: unknown) {
logger.warn('Failed to load sort config from localStorage');
}
return { field: 'created_at', direction: 'asc' as ReportSortDirection };
@@ -153,7 +153,7 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
useEffect(() => {
try {
localStorage.setItem('reportsQueue_sortConfig', JSON.stringify(sortConfig));
} catch (error) {
} catch (error: unknown) {
logger.warn('Failed to save sort config to localStorage');
}
}, [sortConfig]);

View File

@@ -77,7 +77,7 @@ export function BlockedUsers() {
action: 'fetch_blocked_users',
count: blockedUsersWithProfiles.length
});
} catch (error) {
} catch (error: unknown) {
logger.error('Error fetching blocked users', {
userId: user.id,
action: 'fetch_blocked_users',
@@ -134,7 +134,7 @@ export function BlockedUsers() {
});
handleSuccess('User unblocked', `You have unblocked @${username}`);
} catch (error) {
} catch (error: unknown) {
logger.error('Error unblocking user', {
userId: user.id,
action: 'unblock_user',

View File

@@ -63,7 +63,7 @@ export function SearchResults({ query, onClose }: SearchResultsProps) {
];
setResults(allResults);
} catch (error) {
} catch (error: unknown) {
console.error('Search error:', error);
} finally {
setLoading(false);

View File

@@ -213,7 +213,7 @@ export function EmailChangeDialog({ open, onOpenChange, currentEmail, userId }:
);
setStep('success');
} catch (error) {
} catch (error: unknown) {
const errorMsg = getErrorMessage(error);
logger.error('Email change failed', {
userId,
@@ -221,7 +221,12 @@ export function EmailChangeDialog({ open, onOpenChange, currentEmail, userId }:
error: errorMsg,
});
if (error.message?.includes('rate limit') || error.status === 429) {
const hasMessage = error instanceof Error || (typeof error === 'object' && error !== null && 'message' in error);
const hasStatus = typeof error === 'object' && error !== null && 'status' in error;
const errorMessage = hasMessage ? (error as { message: string }).message : '';
const errorStatus = hasStatus ? (error as { status: number }).status : 0;
if (errorMessage.includes('rate limit') || errorStatus === 429) {
handleError(
new AppError(
'Please wait a few minutes before trying again.',
@@ -230,7 +235,7 @@ export function EmailChangeDialog({ open, onOpenChange, currentEmail, userId }:
),
{ action: 'Change email', userId, metadata: { currentEmail, newEmail: data.newEmail } }
);
} else if (error.message?.includes('Invalid login credentials')) {
} else if (errorMessage.includes('Invalid login credentials')) {
handleError(
new AppError(
'The password you entered is incorrect.',

View File

@@ -50,7 +50,7 @@ export function EmailChangeStatus({
newEmailVerified: emailData.new_email_verified || false
});
}
} catch (error) {
} catch (error: unknown) {
handleError(error, { action: 'Check verification status' });
} finally {
setLoading(false);
@@ -77,7 +77,7 @@ export function EmailChangeStatus({
'Verification emails resent',
'Check your inbox for the verification links.'
);
} catch (error) {
} catch (error: unknown) {
handleError(error, { action: 'Resend verification emails' });
} finally {
setResending(false);

View File

@@ -81,7 +81,7 @@ export function PasswordUpdateDialog({ open, onOpenChange, onSuccess }: Password
const hasVerifiedTotp = data?.totp?.some(factor => factor.status === 'verified') || false;
setHasMFA(hasVerifiedTotp);
} catch (error) {
} catch (error: unknown) {
logger.error('Failed to check MFA status', {
action: 'check_mfa_status',
error: error instanceof Error ? error.message : String(error)