From eecdfaa847644c2e982082e37de64ee8b48669d3 Mon Sep 17 00:00:00 2001 From: Vadim Malanov Date: Wed, 13 May 2026 16:46:56 +0300 Subject: [PATCH] fix(frontend): clear TypeScript strict-mode errors - vite-env.d.ts now declares ImportMetaEnv with the three VITE_* variables the project uses, restoring proper typing for import.meta.env in apiClient.ts. - QualityFlag.tsx widens its 'flags' prop to accept the domain QualityFlags type, the loose Record form used in mocks, or null, ending the structural-mismatch errors at five callsites (DocumentsPage, DocumentViewerPage, QualityControlPage, ChunkPreview, SearchResultCard). - DashboardPage trend callbacks are typed against DashboardStats so the implicit-any complaints disappear without weakening intent. npx tsc --noEmit -> clean. vite build -> ok. Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/src/components/common/QualityFlag.tsx | 12 ++++++++++-- frontend/src/pages/DashboardPage.tsx | 5 +++-- frontend/src/vite-env.d.ts | 11 +++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 frontend/src/vite-env.d.ts diff --git a/frontend/src/components/common/QualityFlag.tsx b/frontend/src/components/common/QualityFlag.tsx index 5ab35db..11c3d87 100644 --- a/frontend/src/components/common/QualityFlag.tsx +++ b/frontend/src/components/common/QualityFlag.tsx @@ -1,5 +1,6 @@ import { AlertTriangle, CheckCircle2, FileWarning, Hash, Image, PenLine, Table } from "lucide-react"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; +import type { QualityFlags as QualityFlagsDomain } from "@/services/types"; import { cn } from "@/lib/utils"; const FLAGS: Record< @@ -15,16 +16,23 @@ const FLAGS: Record< needs_manual_review: { label: "Needs manual review", icon: AlertTriangle, tone: "text-warning" }, }; +export type FlagInput = + | QualityFlagsDomain + | Record + | null + | undefined; + export function QualityFlags({ flags, compact = false, className, }: { - flags: Record | null | undefined; + flags: FlagInput; compact?: boolean; className?: string; }) { - const active = Object.entries(flags ?? {}) + const flagMap = (flags ?? {}) as Record; + const active = Object.entries(flagMap) .filter(([k, v]) => v && FLAGS[k]) .map(([k]) => k); diff --git a/frontend/src/pages/DashboardPage.tsx b/frontend/src/pages/DashboardPage.tsx index ee1f54f..f3c70ae 100644 --- a/frontend/src/pages/DashboardPage.tsx +++ b/frontend/src/pages/DashboardPage.tsx @@ -1,5 +1,6 @@ import { FileText, Layers, ShieldAlert, Sparkles, Cpu, Database } from "lucide-react"; +import type { DashboardStats } from "@/services/types"; import { PageHeader } from "@/components/common/PageHeader"; import { Button } from "@/components/ui/button"; import { KpiCard } from "@/widgets/KpiCard"; @@ -39,7 +40,7 @@ export function DashboardPage() { delta={4.2} icon={} tone="primary" - trend={data?.daily_ingest.slice(-12).map((d) => d.ingested) ?? []} + trend={data?.daily_ingest.slice(-12).map((d: DashboardStats["daily_ingest"][number]) => d.ingested) ?? []} /> } tone="success" - trend={data?.ocr_distribution.map((d) => d.count) ?? []} + trend={data?.ocr_distribution.map((d: DashboardStats["ocr_distribution"][number]) => d.count) ?? []} /> + +interface ImportMetaEnv { + readonly VITE_API_BASE_URL?: string; + readonly VITE_USE_MOCK?: string; + readonly VITE_APP_NAME?: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +}