From e76074869bb3280a544af1a7042e497e7f488de6 Mon Sep 17 00:00:00 2001 From: luciano Date: Thu, 7 May 2026 13:49:52 +0200 Subject: [PATCH] fix(web): typecheck stricti per build di produzione MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quattro fix di tipi che emergono solo durante `next build` (con Next.js che esegue typecheck stretto su tutta l'app), pre-esistenti su main: - `fast-timer.tsx`: l'omitted-vs-undefined di `exactOptionalPropertyTypes` rifiuta `{other: undefined}` per un campo opzionale. Costruisco l'oggetto symptoms condizionalmente. - `plan-week.tsx`: `slots[0]` con `noUncheckedIndexedAccess` è `Slot | undefined`. Optional chaining `slots[0]?.meal`. - `profile-form.tsx` e `weight-entry-form.tsx`: il mismatch Zod 3 + RHF + `exactOptionalPropertyTypes` sul tipo del Resolver è noto e non sistemabile senza upgrade. Cast locale del solo zodResolver, runtime invariato. Lint pulito, 99/99 test verdi, `next build` ok in locale. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/web/src/app/[locale]/fasting/fast-timer.tsx | 8 +++++--- apps/web/src/app/[locale]/plan/plan-week.tsx | 2 +- apps/web/src/app/[locale]/profile/profile-form.tsx | 7 ++++++- apps/web/src/app/[locale]/tracking/weight-entry-form.tsx | 7 ++++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/apps/web/src/app/[locale]/fasting/fast-timer.tsx b/apps/web/src/app/[locale]/fasting/fast-timer.tsx index 28f7c99..737b123 100644 --- a/apps/web/src/app/[locale]/fasting/fast-timer.tsx +++ b/apps/web/src/app/[locale]/fasting/fast-timer.tsx @@ -257,13 +257,15 @@ function SymptomsDiary({ event }: { event: FastEventRow }) { function save(): void { startTransition(async () => { setSaved(false); - const result = await updateFastSymptoms(event.id, { + const symptoms: Parameters[1] = { headache, energy, hunger, clarity, - other: other.trim() || undefined, - }); + }; + const trimmedOther = other.trim(); + if (trimmedOther) symptoms.other = trimmedOther; + const result = await updateFastSymptoms(event.id, symptoms); if (result.ok) { setSaved(true); window.setTimeout(() => setSaved(false), 2500); diff --git a/apps/web/src/app/[locale]/plan/plan-week.tsx b/apps/web/src/app/[locale]/plan/plan-week.tsx index daea98d..41a07c1 100644 --- a/apps/web/src/app/[locale]/plan/plan-week.tsx +++ b/apps/web/src/app/[locale]/plan/plan-week.tsx @@ -139,7 +139,7 @@ export function PlanWeek({ // Nessuno slot → giorno di digiuno completo (ESE_24). const isFastingDay = slots.length === 0; // Solo CENA con dailyKcal ridotto → giorno "leggero" del 5:2. - const isLightDay = !isFastingDay && slots.length === 1 && slots[0].meal === 'CENA'; + const isLightDay = !isFastingDay && slots.length === 1 && slots[0]?.meal === 'CENA'; return (
diff --git a/apps/web/src/app/[locale]/profile/profile-form.tsx b/apps/web/src/app/[locale]/profile/profile-form.tsx index 2fa8cd2..6148881 100644 --- a/apps/web/src/app/[locale]/profile/profile-form.tsx +++ b/apps/web/src/app/[locale]/profile/profile-form.tsx @@ -1,6 +1,11 @@ 'use client'; -import { zodResolver } from '@hookform/resolvers/zod'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +import { zodResolver as zodResolverRaw } from '@hookform/resolvers/zod'; +// Cast: zod 3.x + RHF + exactOptionalPropertyTypes generano un mismatch noto; +// il resolver runtime funziona, è solo un'incompatibilità sui tipi opzionali. +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const zodResolver: any = zodResolverRaw; import { ACTIVITY_LEVELS, DIET_HISTORIES, diff --git a/apps/web/src/app/[locale]/tracking/weight-entry-form.tsx b/apps/web/src/app/[locale]/tracking/weight-entry-form.tsx index f02b038..1996100 100644 --- a/apps/web/src/app/[locale]/tracking/weight-entry-form.tsx +++ b/apps/web/src/app/[locale]/tracking/weight-entry-form.tsx @@ -1,6 +1,11 @@ 'use client'; -import { zodResolver } from '@hookform/resolvers/zod'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +import { zodResolver as zodResolverRaw } from '@hookform/resolvers/zod'; +// Cast: zod 3.x + RHF + exactOptionalPropertyTypes generano un mismatch noto; +// il resolver runtime funziona, è solo un'incompatibilità sui tipi opzionali. +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const zodResolver: any = zodResolverRaw; import { weightEntryInputSchema, type WeightEntryInput } from '@ketopath/shared'; import { useTranslations } from 'next-intl'; import { useState } from 'react';