fix: resolve all 58 TypeScript errors across codebase
All checks were successful
CI / update (push) Successful in 2m10s

- 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 3b805861cf
commit a5f2a1d6de
20 changed files with 49 additions and 39 deletions

View File

@@ -1,7 +1,8 @@
import { browser } from '$app/environment';
import { error } from '@sveltejs/kit';
import type { LayoutLoad } from './$types';
export async function load({ params, data }) {
export const load: LayoutLoad = async ({ params, data }) => {
// Validate recipeLang parameter
if (params.recipeLang !== 'rezepte' && params.recipeLang !== 'recipes') {
throw error(404, 'Not found');
@@ -31,4 +32,4 @@ export async function load({ params, data }) {
recipeLang: params.recipeLang,
isOffline: false
};
}
};

View File

@@ -2,8 +2,9 @@ import { browser } from '$app/environment';
import { isOffline, canUseOfflineData } from '$lib/offline/helpers';
import { getAllBriefRecipes, getBriefRecipesBySeason, isOfflineDataAvailable } from '$lib/offline/db';
import { rand_array } from '$lib/js/randomize';
import type { PageLoad } from './$types';
export async function load({ data }) {
export const load: PageLoad = async ({ data }) => {
// On the server, just pass through the server data unchanged
if (!browser) {
return {
@@ -48,4 +49,4 @@ export async function load({ data }) {
...data,
isOffline: false
};
}
};

View File

@@ -1,5 +1,5 @@
import { redirect, error } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import type { PageServerLoad, Actions } from './$types';
import { stripHtmlTags } from '$lib/js/stripHtmlTags';
export const load: PageServerLoad = async ({ fetch, params, locals }) => {
@@ -31,7 +31,7 @@ export const load: PageServerLoad = async ({ fetch, params, locals }) => {
};
};
export const actions = {
export const actions: Actions = {
toggleFavorite: async ({ request, locals, url, fetch }) => {
const session = await locals.auth();

View File

@@ -3,8 +3,9 @@ import { generateRecipeJsonLd } from '$lib/js/recipeJsonLd';
import { isOffline, canUseOfflineData } from '$lib/offline/helpers';
import { getFullRecipe, isOfflineDataAvailable } from '$lib/offline/db';
import { stripHtmlTags } from '$lib/js/stripHtmlTags';
import type { PageLoad } from './$types';
export async function load({ fetch, params, url, data }) {
export const load: PageLoad = async ({ fetch, params, url, data }) => {
const isEnglish = params.recipeLang === 'recipes';
// Check if we need to load from IndexedDB (offline mode)
@@ -200,4 +201,4 @@ export async function load({ fetch, params, url, data }) {
strippedDescription,
isOffline: isOfflineMode,
};
}
};

View File

@@ -2,8 +2,9 @@ import { browser } from '$app/environment';
import { isOffline, canUseOfflineData } from '$lib/offline/helpers';
import { getBriefRecipesByCategory, isOfflineDataAvailable } from '$lib/offline/db';
import { rand_array } from '$lib/js/randomize';
import type { PageLoad } from './$types';
export async function load({ data, params }) {
export const load: PageLoad = async ({ data, params }) => {
// On the server, just pass through the server data unchanged
if (!browser) {
return {
@@ -37,4 +38,4 @@ export async function load({ data, params }) {
...data,
isOffline: false
};
}
};

View File

@@ -2,8 +2,9 @@ import { browser } from '$app/environment';
import { isOffline, canUseOfflineData } from '$lib/offline/helpers';
import { getBriefRecipesByIcon, getAllBriefRecipes, isOfflineDataAvailable } from '$lib/offline/db';
import { rand_array } from '$lib/js/randomize';
import type { PageLoad } from './$types';
export async function load({ data, params }) {
export const load: PageLoad = async ({ data, params }) => {
// On the server, just pass through the server data unchanged
if (!browser) {
return {
@@ -49,4 +50,4 @@ export async function load({ data, params }) {
...data,
isOffline: false
};
}
};

View File

@@ -2,8 +2,9 @@ import { browser } from '$app/environment';
import { isOffline, canUseOfflineData } from '$lib/offline/helpers';
import { getBriefRecipesBySeason, isOfflineDataAvailable } from '$lib/offline/db';
import { rand_array } from '$lib/js/randomize';
import type { PageLoad } from './$types';
export async function load({ data }) {
export const load: PageLoad = async ({ data }) => {
// On the server, just pass through the server data unchanged
if (!browser) {
return {
@@ -38,4 +39,4 @@ export async function load({ data }) {
...data,
isOffline: false
};
}
};

View File

@@ -2,8 +2,9 @@ import { browser } from '$app/environment';
import { isOffline, canUseOfflineData } from '$lib/offline/helpers';
import { getBriefRecipesBySeason, isOfflineDataAvailable } from '$lib/offline/db';
import { rand_array } from '$lib/js/randomize';
import type { PageLoad } from './$types';
export async function load({ data, params }) {
export const load: PageLoad = async ({ data, params }) => {
// On the server, just pass through the server data unchanged
if (!browser) {
return {
@@ -38,4 +39,4 @@ export async function load({ data, params }) {
...data,
isOffline: false
};
}
};

View File

@@ -2,8 +2,9 @@ import { browser } from '$app/environment';
import { isOffline, canUseOfflineData } from '$lib/offline/helpers';
import { getBriefRecipesByTag, isOfflineDataAvailable } from '$lib/offline/db';
import { rand_array } from '$lib/js/randomize';
import type { PageLoad } from './$types';
export async function load({ data, params }) {
export const load: PageLoad = async ({ data, params }) => {
// On the server, just pass through the server data unchanged
if (!browser) {
return {
@@ -37,4 +38,4 @@ export async function load({ data, params }) {
...data,
isOffline: false
};
}
};