fix: Add type annotations for better type safety in recipe parsers
This commit is contained in:
@@ -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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user