chore: clear all svelte-check errors and warnings repo-wide (454 → 0)
Mostly additive JSDoc/TS type annotations and null/undefined guards —
no runtime behavior changes. Starting baseline: 454 errors + 1 warning
across ~50 files. After: 0/0, build is clean.
Highlights:
- Duplicate object-literal keys fixed: 11 in cospendI18n.ts, 2 in
fitnessI18n.ts (dropped second `loading`; renamed `protein_per_kg`
stats-card label to reuse `protein`), 1 in shoppingCategorizer.
- `bind:this` state declared with `HTMLDivElement | null` across
DatePicker + Muscle{Map,Filter,Heatmap}.
- SaveFab's required `onclick` made optional (type="submit" handles
form submission in most callsites).
- Implicit any on ~200 callback parameters replaced with concrete
JSDoc/TS types. Chart.js generics and one mongoose query chain cast
are the only `any` / `unknown as any[]` uses introduced.
- Stats history discriminated union (`paired: true | false`) lets the
template narrow `series` and `stats` properly.
- Food page server guards use `throw new Error('unreachable')` after
`errorWithVerse(...)` awaits so TS narrows `entry`/`recipe`/`meal`
below. Same pattern applied to cospend payments, calendar detail,
and prayers server loads.
- Mongo `Date → string` serialization helper in cospend list so
`IShoppingItem[]` fits `ShoppingItem[]` at the boundary.
- Recipe category/tag pages use a local `RecipeItem` alias (derived
from `BriefRecipeType`) so `rand_array`/filter callbacks type.
- `web-haptics/svelte` has no bundled `.d.ts`; added a local
`@ts-expect-error` shim on the one import line.
Files touched: ~50 across fitness, cospend, faith, recipe, and shared
lib components / API routes.
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
});
|
||||
|
||||
// Parse amount string to number (simplified from nutrition.svelte.ts)
|
||||
/** @param {string | undefined | null} amount */
|
||||
function parseAmount(amount) {
|
||||
if (!amount?.trim()) return 0;
|
||||
let s = amount.trim().replace(',', '.');
|
||||
@@ -69,6 +70,7 @@
|
||||
|
||||
// Compute total recipe nutrition (all ingredients at multiplier=1)
|
||||
const recipeTotals = $derived.by(() => {
|
||||
/** @type {Record<string, number>} */
|
||||
const result = {};
|
||||
const nutrientKeys = [
|
||||
'calories', 'protein', 'fat', 'saturatedFat', 'carbs', 'fiber', 'sugars',
|
||||
@@ -120,6 +122,7 @@
|
||||
const per100g = $derived.by(() => {
|
||||
const w = recipeTotals.totalWeightGrams;
|
||||
if (w <= 0) return recipeTotals.totals;
|
||||
/** @type {Record<string, number>} */
|
||||
const result = {};
|
||||
for (const [k, v] of Object.entries(recipeTotals.totals)) {
|
||||
result[k] = v / w * 100;
|
||||
|
||||
@@ -994,7 +994,7 @@ button:disabled {
|
||||
<button class="btn-secondary" onclick={handleSkip}>
|
||||
Skip Translation
|
||||
</button>
|
||||
<button class="btn-primary" onclick={handleAutoTranslate} disabled={untranslatedBaseRecipes.length > 0}>
|
||||
<button class="btn-primary" onclick={() => handleAutoTranslate()} disabled={untranslatedBaseRecipes.length > 0}>
|
||||
{#if untranslatedBaseRecipes.length > 0}
|
||||
Translate base recipes first
|
||||
{:else}
|
||||
|
||||
Reference in New Issue
Block a user