|
3 | 3 | import * as React from "react"; |
4 | 4 | import * as RechartsPrimitive from "recharts"; |
5 | 5 | import { type Payload } from "recharts/types/component/DefaultTooltipContent"; |
6 | | -import type { ChartDataPayload, ChartIndicator } from "recharts/types/component/DefaultTooltipContent"; |
7 | 6 | import type { LegendProps } from "recharts/types/component/Legend"; |
8 | 7 | import type { TooltipProps } from "recharts/types/component/Tooltip"; |
9 | 8 |
|
@@ -105,13 +104,13 @@ ${colorConfig |
105 | 104 | }; |
106 | 105 |
|
107 | 106 | // Define explicit prop types using Recharts types |
108 | | -interface ChartTooltipProps extends TooltipProps<number | string, string> { |
109 | | - indicator?: ChartIndicator; |
| 107 | +interface ChartTooltipProps extends RechartsPrimitive.TooltipProps<number | string, string> { |
| 108 | + indicator?: RechartsPrimitive.ChartIndicator; |
110 | 109 | hideLabel?: boolean; |
111 | 110 | hideIndicator?: boolean; |
112 | 111 | labelKey?: string; |
113 | 112 | labelFormatter?: (label: string, payload: Payload<number | string, string>[]) => React.ReactNode; |
114 | | - formatter?: (value: number | string | Array<number | string>, name: string, item: Payload<number | string, string>, index: number, payload: ChartDataPayload) => React.ReactNode; |
| 113 | + formatter?: (value: number | string | Array<number | string>, name: string, item: Payload<number | string, string>, index: number, payload: Payload<number | string, string>["payload"] | undefined) => React.ReactNode; |
115 | 114 | color?: string; |
116 | 115 | className?: string; |
117 | 116 | } |
@@ -174,15 +173,15 @@ const ChartTooltip = ({ active, payload, label, className, indicator = "dot", hi |
174 | 173 | const itemColor = typeof item.color === 'string' ? item.color : undefined; |
175 | 174 | const indicatorColor: string = color || itemColor || payloadFill || "hsl(var(--primary))"; |
176 | 175 |
|
177 | | - let formatterPayload: ChartDataPayload = {}; |
| 176 | + let formatterPayload: Payload<number | string, string>["payload"] | undefined = undefined; |
178 | 177 | if ( |
179 | 178 | typeof item.payload === 'object' && |
180 | 179 | item.payload !== null && |
181 | 180 | !(item.payload instanceof Error) |
182 | 181 | ) { |
183 | 182 | // Disable persistent error for this assignment after checks |
184 | 183 | // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment |
185 | | - formatterPayload = item.payload as ChartDataPayload; |
| 184 | + formatterPayload = item.payload; |
186 | 185 | } |
187 | 186 |
|
188 | 187 | const safeValue = (typeof item.value === 'number' || typeof item.value === 'string') ? item.value : 0; |
|
0 commit comments