fix: resolve all 58 TypeScript errors across codebase

- Add SvelteKit PageLoad/LayoutLoad/Actions types to recipe route files
- Fix possibly-undefined access on recipe.images, translations.en
- Fix parseFloat on number types in cospend split validation
- Use discriminated union guards for IngredientItem/InstructionItem
- Fix cache invalidation Promise<number> vs Promise<void> mismatch
- Suppress Mongoose model() complex union type error in WorkoutSession
This commit is contained in:
2026-03-25 07:57:28 +01:00
parent 45bc9fca29
commit d40a7fe7c5
20 changed files with 49 additions and 39 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
function parseTimeToISO8601(timeString: string): string | undefined {
function parseTimeToISO8601(timeString: string | undefined): string | undefined {
if (!timeString) return undefined;
// Handle common German time formats
@@ -66,7 +66,7 @@ export function generateRecipeJsonLd(data: RecipeModelType) {
"name": "Alexander Bocken"
},
"datePublished": data.dateCreated ? new Date(data.dateCreated).toISOString() : undefined,
"dateModified": data.dateModified || data.updatedAt ? new Date(data.dateModified || data.updatedAt).toISOString() : undefined,
"dateModified": data.dateModified ? new Date(data.dateModified).toISOString() : undefined,
"recipeCategory": data.category,
"keywords": data.tags?.join(', '),
"image": {
@@ -98,7 +98,7 @@ export function generateRecipeJsonLd(data: RecipeModelType) {
// Extract ingredients
if (data.ingredients) {
for (const ingredientGroup of data.ingredients) {
if (ingredientGroup.list) {
if ('list' in ingredientGroup && ingredientGroup.list) {
for (const ingredient of ingredientGroup.list) {
if (ingredient.name) {
let ingredientText = ingredient.name;
@@ -115,7 +115,7 @@ export function generateRecipeJsonLd(data: RecipeModelType) {
// Extract instructions
if (data.instructions) {
for (const instructionGroup of data.instructions) {
if (instructionGroup.steps) {
if ('steps' in instructionGroup && instructionGroup.steps) {
for (let i = 0; i < instructionGroup.steps.length; i++) {
jsonLd.recipeInstructions.push({
"@type": "HowToStep",
+1 -1
View File
@@ -312,7 +312,7 @@ export async function invalidateRecipeCaches(): Promise<void> {
*/
export async function invalidateCospendCaches(usernames: string[], paymentId?: string): Promise<void> {
try {
const invalidations: Promise<void>[] = [];
const invalidations: Promise<unknown>[] = [];
// Invalidate balance and debts caches for all affected users
for (const username of usernames) {
+6 -5
View File
@@ -32,17 +32,18 @@ export function briefQueryConfig(recipeLang: string) {
*/
export function toBrief(recipe: RecipeModelType, recipeLang: string): BriefRecipeType {
if (isEnglish(recipeLang)) {
const en = recipe.translations?.en;
return {
_id: recipe._id,
name: recipe.translations.en.name,
short_name: recipe.translations.en.short_name,
name: en?.name ?? '',
short_name: en?.short_name ?? '',
images: recipe.images?.[0]
? [{ alt: recipe.images[0].alt, mediapath: recipe.images[0].mediapath, color: recipe.images[0].color }]
: [],
tags: recipe.translations.en.tags || [],
category: recipe.translations.en.category,
tags: en?.tags || [],
category: en?.category ?? '',
icon: recipe.icon,
description: recipe.translations.en.description,
description: en?.description,
season: recipe.season || [],
dateCreated: recipe.dateCreated,
dateModified: recipe.dateModified,