fix: Add type annotations for better type safety in recipe parsers

This commit is contained in:
Nils-Johan Gynther
2026-04-12 09:41:35 +02:00
parent 4e2616fe2e
commit 0e18f382c8
2 changed files with 6 additions and 6 deletions
@@ -25,7 +25,7 @@ export class GenericRecipeParser extends RecipeParser {
const recipe = const recipe =
jsonData['@type'] === 'Recipe' jsonData['@type'] === 'Recipe'
? jsonData ? jsonData
: jsonData['@graph']?.find((item) => item['@type'] === 'Recipe'); : jsonData['@graph']?.find((item: any) => item['@type'] === 'Recipe');
if (recipe) { if (recipe) {
console.log('[GenericParser] ✓ JSON-LD data found'); console.log('[GenericParser] ✓ JSON-LD data found');
@@ -59,12 +59,12 @@ export class GenericRecipeParser extends RecipeParser {
instructions = recipe.recipeInstructions; instructions = recipe.recipeInstructions;
} else if (Array.isArray(recipe.recipeInstructions)) { } else if (Array.isArray(recipe.recipeInstructions)) {
instructions = recipe.recipeInstructions instructions = recipe.recipeInstructions
.map((step) => { .map((step: any) => {
if (typeof step === 'string') return step; if (typeof step === 'string') return step;
if (step.text) return step.text; if (step.text) return step.text;
return ''; return '';
}) })
.filter((s) => s) .filter((s: string) => s)
.join('\n\n'); .join('\n\n');
} }
} }
@@ -25,7 +25,7 @@ export class IcaRecipeParser extends RecipeParser {
const recipe = const recipe =
jsonData['@type'] === 'Recipe' jsonData['@type'] === 'Recipe'
? jsonData ? jsonData
: jsonData['@graph']?.find((item) => item['@type'] === 'Recipe'); : jsonData['@graph']?.find((item: any) => item['@type'] === 'Recipe');
if (recipe) { if (recipe) {
console.log('[IcaParser] ✓ JSON-LD recipe found'); console.log('[IcaParser] ✓ JSON-LD recipe found');
@@ -63,12 +63,12 @@ export class IcaRecipeParser extends RecipeParser {
instructions = recipe.recipeInstructions; instructions = recipe.recipeInstructions;
} else if (Array.isArray(recipe.recipeInstructions)) { } else if (Array.isArray(recipe.recipeInstructions)) {
instructions = recipe.recipeInstructions instructions = recipe.recipeInstructions
.map((step) => { .map((step: any) => {
if (typeof step === 'string') return step; if (typeof step === 'string') return step;
if (step.text) return step.text; if (step.text) return step.text;
return ''; return '';
}) })
.filter((s) => s) .filter((s: string) => s)
.join('\n\n'); .join('\n\n');
} }
} }