fix: resolve all 1008 svelte-check type errors across codebase
Add type annotations, JSDoc types, null checks, and proper generics to eliminate all svelte-check errors. Key changes include: - Type $state(null) variables to avoid 'never' inference - Add JSDoc typedefs for plain <script> components - Fix mongoose model typing with Model<any> to avoid union complexity - Add App.Error/App.PageState interfaces in app.d.ts - Fix tuple types to array types in types.ts - Type catch block errors and API handler params - Add null safety for DOM queries and optional chaining - Add standard line-clamp property alongside -webkit- prefix
This commit is contained in:
@@ -57,22 +57,22 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
|
||||
// Ensure translations.en.images array exists and has the right length
|
||||
if (!recipe.translations) {
|
||||
recipe.translations = { en: { images: [] } };
|
||||
(recipe as any).translations = { en: { images: [] } };
|
||||
}
|
||||
if (!recipe.translations.en) {
|
||||
recipe.translations.en = { images: [] };
|
||||
if (!recipe.translations!.en) {
|
||||
(recipe.translations as any).en = { images: [] };
|
||||
}
|
||||
if (!recipe.translations.en.images) {
|
||||
recipe.translations.en.images = [];
|
||||
if (!recipe.translations!.en!.images) {
|
||||
(recipe.translations!.en as any).images = [];
|
||||
}
|
||||
|
||||
// Ensure the en.images array has entries for all images
|
||||
while (recipe.translations.en.images.length <= imageIndex) {
|
||||
recipe.translations.en.images.push({ alt: '', caption: '' });
|
||||
while (recipe.translations!.en!.images!.length <= imageIndex) {
|
||||
recipe.translations!.en!.images!.push({ alt: '', caption: '' } as any);
|
||||
}
|
||||
|
||||
// Update English alt text
|
||||
recipe.translations.en.images[imageIndex].alt = altTextResult.en;
|
||||
recipe.translations!.en!.images![imageIndex].alt = altTextResult.en;
|
||||
|
||||
// Save to database
|
||||
await recipe.save();
|
||||
|
||||
Reference in New Issue
Block a user