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 { AlertTriangle, CheckCircle2, FileWarning, Hash, Image, PenLine, Table } from "lucide-react";
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
|
import type { QualityFlags as QualityFlagsDomain } from "@/services/types";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
const FLAGS: Record<
|
const FLAGS: Record<
|
||||||
@@ -15,16 +16,23 @@ const FLAGS: Record<
|
|||||||
needs_manual_review: { label: "Needs manual review", icon: AlertTriangle, tone: "text-warning" },
|
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({
|
export function QualityFlags({
|
||||||
flags,
|
flags,
|
||||||
compact = false,
|
compact = false,
|
||||||
className,
|
className,
|
||||||
}: {
|
}: {
|
||||||
flags: Record<string, boolean | undefined> | null | undefined;
|
flags: FlagInput;
|
||||||
compact?: boolean;
|
compact?: boolean;
|
||||||
className?: string;
|
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])
|
.filter(([k, v]) => v && FLAGS[k])
|
||||||
.map(([k]) => k);
|
.map(([k]) => k);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { FileText, Layers, ShieldAlert, Sparkles, Cpu, Database } from "lucide-react";
|
import { FileText, Layers, ShieldAlert, Sparkles, Cpu, Database } from "lucide-react";
|
||||||
|
|
||||||
|
import type { DashboardStats } from "@/services/types";
|
||||||
import { PageHeader } from "@/components/common/PageHeader";
|
import { PageHeader } from "@/components/common/PageHeader";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { KpiCard } from "@/widgets/KpiCard";
|
import { KpiCard } from "@/widgets/KpiCard";
|
||||||
@@ -39,7 +40,7 @@ export function DashboardPage() {
|
|||||||
delta={4.2}
|
delta={4.2}
|
||||||
icon={<FileText className="h-4 w-4" />}
|
icon={<FileText className="h-4 w-4" />}
|
||||||
tone="primary"
|
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
|
<KpiCard
|
||||||
label="OCR confidence"
|
label="OCR confidence"
|
||||||
@@ -48,7 +49,7 @@ export function DashboardPage() {
|
|||||||
delta={1.3}
|
delta={1.3}
|
||||||
icon={<Layers className="h-4 w-4" />}
|
icon={<Layers className="h-4 w-4" />}
|
||||||
tone="success"
|
tone="success"
|
||||||
trend={data?.ocr_distribution.map((d) => d.count) ?? []}
|
trend={data?.ocr_distribution.map((d: DashboardStats["ocr_distribution"][number]) => d.count) ?? []}
|
||||||
/>
|
/>
|
||||||
<KpiCard
|
<KpiCard
|
||||||
label="Needs manual review"
|
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