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:
2026-03-02 08:40:15 +01:00
parent 9c50133dfe
commit d2ac67fb44
125 changed files with 871 additions and 600 deletions
+2 -2
View File
@@ -42,7 +42,7 @@ export const GET: RequestHandler = async ({ locals }) => {
.lean();
// Get all other users who have splits with payments involving the current user
const paymentIds = userSplits.map(split => split.paymentId._id);
const paymentIds = userSplits.map(split => (split.paymentId as any)._id);
const allRelatedSplits = await PaymentSplit.find({
paymentId: { $in: paymentIds },
username: { $ne: currentUser }
@@ -60,7 +60,7 @@ export const GET: RequestHandler = async ({ locals }) => {
// Find other participants in this payment
const otherSplits = allRelatedSplits.filter(s =>
s.paymentId._id.toString() === split.paymentId._id.toString()
(s.paymentId as any)._id.toString() === (split.paymentId as any)._id.toString()
);
for (const otherSplit of otherSplits) {
@@ -76,7 +76,7 @@ export const GET: RequestHandler = async ({ url, locals }) => {
}
];
const results = await Payment.aggregate(pipeline);
const results = await Payment.aggregate(pipeline as any);
// Transform data into chart-friendly format
const monthsMap = new Map();
@@ -106,13 +106,13 @@ export const GET: RequestHandler = async ({ url, locals }) => {
// Convert to arrays for Chart.js
const allMonths = Array.from(monthsMap.keys()).sort();
const categoryList = Array.from(categories).sort();
const categoryList = Array.from(categories).sort() as string[];
// Find the first month with any data and trim empty months from the start
let firstMonthWithData = 0;
for (let i = 0; i < allMonths.length; i++) {
const monthData = monthsMap.get(allMonths[i]);
const hasData = Object.values(monthData).some(value => value > 0);
const hasData = Object.values(monthData).some((value: any) => value > 0);
if (hasData) {
firstMonthWithData = i;
break;
+2 -2
View File
@@ -102,7 +102,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
exchangeRate = conversion.exchangeRate;
} catch (e) {
console.error('Currency conversion error:', e);
throw error(400, `Failed to convert ${inputCurrency} to CHF: ${e.message}`);
throw error(400, `Failed to convert ${inputCurrency} to CHF: ${e instanceof Error ? e.message : String(e)}`);
}
}
@@ -146,7 +146,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
};
});
const splitPromises = convertedSplits.map((split) => {
const splitPromises = convertedSplits.map((split: any) => {
return PaymentSplit.create(split);
});
@@ -36,7 +36,7 @@ export const GET: RequestHandler = async ({ params, locals }) => {
await cache.set(cacheKey, JSON.stringify(result), 1800);
return json(result);
} catch (e) {
} catch (e: any) {
if (e.status === 404) throw e;
throw error(500, 'Failed to fetch payment');
} finally {
@@ -108,7 +108,7 @@ export const PUT: RequestHandler = async ({ params, request, locals }) => {
await invalidateCospendCaches(allAffectedUsers, id);
return json({ success: true, payment: updatedPayment });
} catch (e) {
} catch (e: any) {
if (e.status) throw e;
throw error(500, 'Failed to update payment');
} finally {
@@ -148,7 +148,7 @@ export const DELETE: RequestHandler = async ({ params, locals }) => {
await invalidateCospendCaches(affectedUsernames, id);
return json({ success: true });
} catch (e) {
} catch (e: any) {
if (e.status) throw e;
throw error(500, 'Failed to delete payment');
} finally {
+1 -1
View File
@@ -55,7 +55,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
path: publicPath
});
} catch (err) {
} catch (err: any) {
if (err.status) throw err;
console.error('Upload error:', err);
throw error(500, 'Failed to upload file');