From acf8651bd10495101676066166662462bcd40150 Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Sun, 30 Nov 2025 21:16:26 +0400 Subject: [PATCH] refactor: fix types after dependency upgrade --- src/components/traffic-details-dialog.tsx | 8 ++------ src/components/ui/chart.tsx | 24 +++++++++++++++-------- tsconfig.json | 5 +++-- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/components/traffic-details-dialog.tsx b/src/components/traffic-details-dialog.tsx index 9cb5208..138f3d0 100644 --- a/src/components/traffic-details-dialog.tsx +++ b/src/components/traffic-details-dialog.tsx @@ -2,7 +2,6 @@ import { invoke } from "@tauri-apps/api/core"; import * as React from "react"; -import type { TooltipProps } from "recharts"; import { Area, AreaChart, @@ -12,10 +11,7 @@ import { XAxis, YAxis, } from "recharts"; -import type { - NameType, - ValueType, -} from "recharts/types/component/DefaultTooltipContent"; +import type { TooltipContentProps } from "recharts/types/component/Tooltip"; import { Dialog, DialogContent, @@ -140,7 +136,7 @@ export function TrafficDetailsDialog({ // Tooltip render function const renderTooltip = React.useCallback( - (props: TooltipProps) => { + (props: TooltipContentProps) => { const { active, payload, label } = props; if (!active || !payload?.length) return null; diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsx index b093d8a..deca280 100644 --- a/src/components/ui/chart.tsx +++ b/src/components/ui/chart.tsx @@ -2,6 +2,12 @@ import * as React from "react"; import * as RechartsPrimitive from "recharts"; +import type { + Props as DefaultLegendContentProps, + LegendPayload, +} from "recharts/types/component/DefaultLegendContent"; +import type { Payload } from "recharts/types/component/DefaultTooltipContent"; +import type { TooltipContentProps } from "recharts/types/component/Tooltip"; import { cn } from "@/lib/utils"; @@ -105,13 +111,15 @@ const ChartTooltip = RechartsPrimitive.Tooltip; const ChartTooltipContent = React.forwardRef< HTMLDivElement, - React.ComponentProps & + TooltipContentProps & React.ComponentProps<"div"> & { hideLabel?: boolean; hideIndicator?: boolean; indicator?: "line" | "dot" | "dashed"; nameKey?: string; labelKey?: string; + labelClassName?: string; + color?: string; } >( ( @@ -187,15 +195,15 @@ const ChartTooltipContent = React.forwardRef< {!nestLabel ? tooltipLabel : null}
{payload - .filter((item) => item.type !== "none") - .map((item, index) => { + .filter((item: Payload) => item.type !== "none") + .map((item: Payload, index: number) => { const key = `${nameKey || item.name || item.dataKey || "value"}`; const itemConfig = getPayloadConfigFromPayload(config, item, key); - const indicatorColor = color || item.payload.fill || item.color; + const indicatorColor = color || item.payload?.fill || item.color; return (
svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground", indicator === "dot" && "items-center", @@ -264,7 +272,7 @@ const ChartLegend = RechartsPrimitive.Legend; const ChartLegendContent = React.forwardRef< HTMLDivElement, React.ComponentProps<"div"> & - Pick & { + Pick & { hideIcon?: boolean; nameKey?: string; } @@ -289,8 +297,8 @@ const ChartLegendContent = React.forwardRef< )} > {payload - .filter((item) => item.type !== "none") - .map((item) => { + .filter((item: LegendPayload) => item.type !== "none") + .map((item: LegendPayload) => { const key = `${nameKey || item.dataKey || "value"}`; const itemConfig = getPayloadConfigFromPayload(config, item, key); diff --git a/tsconfig.json b/tsconfig.json index e69f93d..5521c8f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve", + "jsx": "react-jsx", "incremental": true, "plugins": [ { @@ -29,7 +29,8 @@ "**/*.tsx", ".next/types/**/*.ts", "next-env.d.ts", - "dist/types/**/*.ts" + "dist/types/**/*.ts", + ".next/dev/types/**/*.ts" ], "exclude": ["node_modules", "nodecar", "src-tauri/target"] }