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) <noreply@anthropic.com>
This commit is contained in:
@@ -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<string, boolean | undefined>
|
||||
| null
|
||||
| undefined;
|
||||
|
||||
export function QualityFlags({
|
||||
flags,
|
||||
compact = false,
|
||||
className,
|
||||
}: {
|
||||
flags: Record<string, boolean | undefined> | null | undefined;
|
||||
flags: FlagInput;
|
||||
compact?: boolean;
|
||||
className?: string;
|
||||
}) {
|
||||
const active = Object.entries(flags ?? {})
|
||||
const flagMap = (flags ?? {}) as Record<string, boolean | undefined>;
|
||||
const active = Object.entries(flagMap)
|
||||
.filter(([k, v]) => v && FLAGS[k])
|
||||
.map(([k]) => k);
|
||||
|
||||
|
||||
@@ -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={<FileText className="h-4 w-4" />}
|
||||
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) ?? []}
|
||||
/>
|
||||
<KpiCard
|
||||
label="OCR confidence"
|
||||
@@ -48,7 +49,7 @@ export function DashboardPage() {
|
||||
delta={1.3}
|
||||
icon={<Layers className="h-4 w-4" />}
|
||||
tone="success"
|
||||
trend={data?.ocr_distribution.map((d) => d.count) ?? []}
|
||||
trend={data?.ocr_distribution.map((d: DashboardStats["ocr_distribution"][number]) => d.count) ?? []}
|
||||
/>
|
||||
<KpiCard
|
||||
label="Needs manual review"
|
||||
|
||||
11
frontend/src/vite-env.d.ts
vendored
Normal file
11
frontend/src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_API_BASE_URL?: string;
|
||||
readonly VITE_USE_MOCK?: string;
|
||||
readonly VITE_APP_NAME?: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
Reference in New Issue
Block a user