Fix: Enable TypeScript strict mode

This commit is contained in:
gpt-engineer-app[bot]
2025-10-20 00:26:49 +00:00
parent 84188b94f2
commit d9a912f443
11 changed files with 174 additions and 29 deletions

View File

@@ -4,7 +4,7 @@ import { logger } from './logger';
export type ErrorContext = {
action: string;
userId?: string;
metadata?: Record<string, any>;
metadata?: Record<string, unknown>;
};
export class AppError extends Error {
@@ -66,11 +66,27 @@ export const handleInfo = (
* Type-safe error message extraction utility
* Use this instead of `error: any` in catch blocks
*/
export const getErrorMessage = (error: unknown): string => {
if (error instanceof Error) return error.message;
if (typeof error === 'string') return error;
export function getErrorMessage(error: unknown): string {
if (error instanceof Error) {
return error.message;
}
if (typeof error === 'string') {
return error;
}
if (error && typeof error === 'object' && 'message' in error) {
return String(error.message);
}
return 'An unexpected error occurred';
};
}
/**
* Type guard to check if error has a code property
*/
export function hasErrorCode(error: unknown): error is { code: string } {
return (
error !== null &&
typeof error === 'object' &&
'code' in error &&
typeof (error as { code: unknown }).code === 'string'
);
}