Skip to content

Commit a67ac5f

Browse files
alexfauquetteclaude
andcommitted
[charts] Fix DefaultContent formattedValue PropTypes warning
DefaultContent was generic over `T extends CartesianChartSeriesType | PolarChartSeriesType`. With a bare type parameter, the conditional type behind `SeriesItem<T>.formattedValue` (`T extends 'ohlc' ? object : string`) stayed deferred, so the proptypes generator emitted `PropTypes.object` — contradicting the component's runtime guard that only renders string values. This produced a false-positive PropTypes warning for any standard chart using a `valueFormatter` returning a string. Make `DefaultContent` non-generic with a concrete type argument that excludes `'ohlc'` (candlestick provides its own AxisTooltipContent), so the conditional resolves eagerly to `string`. Regenerated proptypes now declare `formattedValue: PropTypes.string.isRequired`. Closes mui#22926 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a57d297 commit a67ac5f

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

packages/x-charts/src/ChartsTooltip/ChartsAxisTooltipContent.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ function ChartsAxisTooltipContent(props: ChartsAxisTooltipContentProps) {
100100
);
101101
}
102102

103-
function DefaultContent<T extends CartesianChartSeriesType | PolarChartSeriesType>(
104-
props: AxisTooltipContentProps<T>,
103+
function DefaultContent(
104+
props: AxisTooltipContentProps<Exclude<CartesianChartSeriesType, 'ohlc'> | PolarChartSeriesType>,
105105
) {
106106
const classes = useUtilityClasses(props.classes);
107107
const { item } = props;
@@ -146,14 +146,24 @@ DefaultContent.propTypes /* remove-proptypes */ = {
146146
item: PropTypes.shape({
147147
color: PropTypes.string.isRequired,
148148
formattedLabel: PropTypes.string,
149-
formattedValue: PropTypes.object.isRequired,
149+
formattedValue: PropTypes.string.isRequired,
150150
markShape: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']),
151151
markType: PropTypes.oneOfType([
152152
PropTypes.oneOf(['circle', 'line', 'line+mark', 'square']),
153153
PropTypes.func,
154154
]),
155155
seriesId: PropTypes.string.isRequired,
156-
value: PropTypes.any.isRequired,
156+
value: PropTypes.oneOfType([
157+
PropTypes.number,
158+
PropTypes.shape({
159+
colorValue: PropTypes.any,
160+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
161+
sizeValue: PropTypes.any,
162+
x: PropTypes.number.isRequired,
163+
y: PropTypes.number.isRequired,
164+
z: PropTypes.any,
165+
}),
166+
]),
157167
}).isRequired,
158168
} as any;
159169

0 commit comments

Comments
 (0)