Problem
frontend/lib/api/admin.ts uses the any type for updateProfile (line 149), getAnalytics (line 201), and several mutation return values. useQuery and useMutation calls throughout the codebase lack generic type parameters. If the backend changes a response shape, TypeScript gives no compile-time warning - runtime errors surface deep inside component render logic.
Proposed Solution
- Create
frontend/lib/types/api.ts with strict response interfaces for every endpoint: DashboardStatsResponse, MenuItemResponse, AdminUserResponse, GalleryImageResponse, ContactSubmissionResponse, AnalyticsResponse
- Create a discriminated union for API errors:
type ApiError = { statusCode: number; message: string; details?: Record<string, string[]> }
- Add Zod schemas for the 5 most critical responses and validate them in the API client
- Apply React Query generics:
useQuery<MenuItemResponse[], ApiError>()
- Enable
noImplicitAny in tsconfig.json
Acceptance Criteria
Problem
frontend/lib/api/admin.tsuses theanytype forupdateProfile(line 149),getAnalytics(line 201), and several mutation return values.useQueryanduseMutationcalls throughout the codebase lack generic type parameters. If the backend changes a response shape, TypeScript gives no compile-time warning - runtime errors surface deep inside component render logic.Proposed Solution
frontend/lib/types/api.tswith strict response interfaces for every endpoint:DashboardStatsResponse,MenuItemResponse,AdminUserResponse,GalleryImageResponse,ContactSubmissionResponse,AnalyticsResponsetype ApiError = { statusCode: number; message: string; details?: Record<string, string[]> }useQuery<MenuItemResponse[], ApiError>()noImplicitAnyintsconfig.jsonAcceptance Criteria
anytype infrontend/lib/api/ZodErrorwith the field name before reaching component statenoImplicitAny: trueintsconfig.jsonuseQuery/useMutationcalls have explicit generic type parameters