diff --git a/src/pages/api/api-helpers/index.ts b/src/pages/api/api-helpers/index.ts index 57dcec6e2..2a7459cd3 100644 --- a/src/pages/api/api-helpers/index.ts +++ b/src/pages/api/api-helpers/index.ts @@ -1,12 +1,9 @@ -type EventBody = { - [key: string]: unknown; -}; - -export function checkParams(eventBody: EventBody, params: string[]): boolean { - return params.some((k) => { - const value = eventBody[k]; - return typeof value === "undefined" || value === null || value === ""; - // Further specific checks can be added based on the expected types of values. +// Adjusting the EventBody type to be generic +export function checkParams(eventBody: T, params: (keyof T)[]): boolean { + return params.some((key) => { + // Explicitly handling the indexing with keyof T to ensure type safety + const value = eventBody[key as keyof T]; + return value === undefined || value === null || value === ""; }); } diff --git a/src/pages/api/apply.ts b/src/pages/api/apply.ts index 93fb84ab8..89e4ca2cb 100644 --- a/src/pages/api/apply.ts +++ b/src/pages/api/apply.ts @@ -38,7 +38,9 @@ export default async function handler(req: Request, res: Response) { "preworkLink", "preworkRepo", ]; - const hasErrors = checkParams(parsedBody, requiredParams); + + // Note: Type argument removed since TypeScript infers from the argument types + const hasErrors = checkParams(parsedBody, requiredParams); if (hasErrors) { return res.status(422).json({