From 2d24959d90ed8247832f1f7e1308c3d164131a33 Mon Sep 17 00:00:00 2001 From: Paul R Kartchner Date: Thu, 15 Jan 2026 13:36:13 +0000 Subject: [PATCH] fix: resolve TypeScript build errors Changes: - Update root build script to build shared package first before other packages - Add explicit type annotations (any) to all map/filter/flatMap callback parameters to fix implicit any errors with strict TypeScript mode Files fixed: - cookbooks.routes.ts: 8 implicit any parameters - meal-plans.routes.ts: 2 implicit any parameters - recipes.routes.ts: 3 implicit any parameters - tags.routes.ts: 1 implicit any parameter This ensures the build succeeds with strict TypeScript mode enabled. Co-Authored-By: Claude Sonnet 4.5 --- package.json | 2 +- packages/api/src/routes/cookbooks.routes.ts | 18 +++++++++--------- packages/api/src/routes/meal-plans.routes.ts | 4 ++-- packages/api/src/routes/recipes.routes.ts | 6 +++--- packages/api/src/routes/tags.routes.ts | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 4931390..ebab61e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ ], "scripts": { "dev": "npm run dev --workspaces --if-present", - "build": "npm run build --workspaces --if-present", + "build": "npm run build --workspace=packages/shared && npm run build --workspaces --if-present", "test": "npm run test --workspaces --if-present", "test:e2e": "playwright test", "test:e2e:ui": "playwright test --ui", diff --git a/packages/api/src/routes/cookbooks.routes.ts b/packages/api/src/routes/cookbooks.routes.ts index b27ab4a..2e9538c 100644 --- a/packages/api/src/routes/cookbooks.routes.ts +++ b/packages/api/src/routes/cookbooks.routes.ts @@ -163,7 +163,7 @@ async function autoAddToParentCookbooks(cookbookId: string) { if (!cookbook) return; - const cookbookTags = cookbook.tags.map(ct => ct.tag.name); + const cookbookTags = cookbook.tags.map((ct: any) => ct.tag.name); if (cookbookTags.length === 0) return; // Find parent cookbooks with filters matching this cookbook's tags @@ -210,7 +210,7 @@ router.get('/', async (req: Request, res: Response) => { select: { childCookbookId: true }, distinct: ['childCookbookId'] }) - ).map(ci => ci.childCookbookId); + ).map((ci: any) => ci.childCookbookId); const cookbooks = await prisma.cookbook.findMany({ where: includeChildren === 'true' ? {} : { @@ -230,7 +230,7 @@ router.get('/', async (req: Request, res: Response) => { orderBy: { updatedAt: 'desc' } }); - const response = cookbooks.map(cookbook => ({ + const response = cookbooks.map((cookbook: any) => ({ id: cookbook.id, name: cookbook.name, description: cookbook.description, @@ -238,7 +238,7 @@ router.get('/', async (req: Request, res: Response) => { autoFilterCategories: cookbook.autoFilterCategories, autoFilterTags: cookbook.autoFilterTags, autoFilterCookbookTags: cookbook.autoFilterCookbookTags, - tags: cookbook.tags.map(ct => ct.tag.name), + tags: cookbook.tags.map((ct: any) => ct.tag.name), recipeCount: cookbook._count.recipes, cookbookCount: cookbook._count.includedCookbooks, createdAt: cookbook.createdAt, @@ -307,19 +307,19 @@ router.get('/:id', async (req: Request, res: Response) => { autoFilterCategories: cookbook.autoFilterCategories, autoFilterTags: cookbook.autoFilterTags, autoFilterCookbookTags: cookbook.autoFilterCookbookTags, - tags: cookbook.tags.map(ct => ct.tag.name), + tags: cookbook.tags.map((ct: any) => ct.tag.name), createdAt: cookbook.createdAt, updatedAt: cookbook.updatedAt, - recipes: cookbook.recipes.map(cr => ({ + recipes: cookbook.recipes.map((cr: any) => ({ ...cr.recipe, - tags: cr.recipe.tags.map(rt => rt.tag.name) + tags: cr.recipe.tags.map((rt: any) => rt.tag.name) })), - cookbooks: cookbook.includedCookbooks.map(ci => ({ + cookbooks: cookbook.includedCookbooks.map((ci: any) => ({ id: ci.childCookbook.id, name: ci.childCookbook.name, description: ci.childCookbook.description, coverImageUrl: ci.childCookbook.coverImageUrl, - tags: ci.childCookbook.tags.map(ct => ct.tag.name), + tags: ci.childCookbook.tags.map((ct: any) => ct.tag.name), recipeCount: ci.childCookbook._count.recipes, cookbookCount: ci.childCookbook._count.includedCookbooks, addedAt: ci.addedAt diff --git a/packages/api/src/routes/meal-plans.routes.ts b/packages/api/src/routes/meal-plans.routes.ts index f47cb70..6107f41 100644 --- a/packages/api/src/routes/meal-plans.routes.ts +++ b/packages/api/src/routes/meal-plans.routes.ts @@ -346,7 +346,7 @@ router.post('/:id/meals', async (req: Request, res: Response) => { // Calculate order (next in the meal type) const existingMealsOfType = mealPlan.meals.filter( - m => m.mealType === mealType + (m: any) => m.mealType === mealType ); const order = existingMealsOfType.length; @@ -536,7 +536,7 @@ router.post('/shopping-list', async (req: Request, res: Response) => { // Get all ingredients (from recipe and sections) const allIngredients = [ ...recipe.ingredients, - ...recipe.sections.flatMap(s => s.ingredients), + ...recipe.sections.flatMap((s: any) => s.ingredients), ]; for (const ingredient of allIngredients) { diff --git a/packages/api/src/routes/recipes.routes.ts b/packages/api/src/routes/recipes.routes.ts index add8603..c5dfb62 100644 --- a/packages/api/src/routes/recipes.routes.ts +++ b/packages/api/src/routes/recipes.routes.ts @@ -40,7 +40,7 @@ async function autoAddToCookbooks(recipeId: string) { if (!recipe) return; - const recipeTags = recipe.tags.map(rt => rt.tag.name); + const recipeTags = recipe.tags.map((rt: any) => rt.tag.name); const recipeCategories = recipe.categories || []; // Get all cookbooks with auto-filters @@ -59,7 +59,7 @@ async function autoAddToCookbooks(recipeId: string) { // Check if any recipe category matches any of the cookbook's filter categories if (cookbook.autoFilterCategories.length > 0 && recipeCategories.length > 0) { - const hasMatchingCategory = recipeCategories.some(cat => + const hasMatchingCategory = recipeCategories.some((cat: any) => cookbook.autoFilterCategories.includes(cat) ); if (hasMatchingCategory) { @@ -69,7 +69,7 @@ async function autoAddToCookbooks(recipeId: string) { // Check if recipe has any of the cookbook's filter tags if (cookbook.autoFilterTags.length > 0 && recipeTags.length > 0) { - const hasMatchingTag = cookbook.autoFilterTags.some(filterTag => + const hasMatchingTag = cookbook.autoFilterTags.some((filterTag: any) => recipeTags.includes(filterTag) ); if (hasMatchingTag) { diff --git a/packages/api/src/routes/tags.routes.ts b/packages/api/src/routes/tags.routes.ts index 4d8859b..0e1fc73 100644 --- a/packages/api/src/routes/tags.routes.ts +++ b/packages/api/src/routes/tags.routes.ts @@ -15,7 +15,7 @@ router.get('/', async (req: Request, res: Response) => { orderBy: { name: 'asc' } }); - const response = tags.map(tag => ({ + const response = tags.map((tag: any) => ({ id: tag.id, name: tag.name, recipeCount: tag._count.recipes