Skip to content

ChartData and DataProvider types have generics#6896

Merged
ckifer merged 1 commit into
mainfrom
DataPointType
Jan 26, 2026
Merged

ChartData and DataProvider types have generics#6896
ckifer merged 1 commit into
mainfrom
DataPointType

Conversation

@PavelVanecek

@PavelVanecek PavelVanecek commented Jan 16, 2026

Copy link
Copy Markdown
Collaborator

Description

Breaking down #6867 into smaller PRs that we can merge easier. The types tend to spread everywhere so I aim trying to isolate smaller chunks - this one is adding a generic to ChartData and DataProvider types. These generics are exposed to charts but

Related Issue

#6645

Types of changes

New feature I think?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

I will add docs once it's done and ready for release

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a storybook story or VR test, or extended an existing story or VR test to show my changes

Summary by CodeRabbit

  • Refactor
    • Improved type safety across chart components by introducing generic data-point typing and a standardized data-provider pattern for more reliable data handling.
  • Stories & Tests
    • Strengthened example stories and tests with explicit data types and runtime null-safety checks to reduce runtime errors and improve developer confidence.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Introduces a generic DataPointType across core types and chart components, replacing direct data?: ChartData props with DataProvider<DataPointType> and retyping exported chart components to expose generic signatures; storybook stories and tests updated with explicit data types and null-safety assertions.

Changes

Cohort / File(s) Summary
Core Type System
src/util/types.ts, src/state/chartDataSlice.ts
Added DataPointType generic to DataProvider, BaseChartProps, CartesianChartProps, PolarChartProps, and ChartData<DataPointType>.
Cartesian Component Props
src/cartesian/Area.tsx, src/cartesian/Line.tsx, src/cartesian/Scatter.tsx, src/cartesian/Funnel.tsx
Prop interfaces made generic (DataPointType = unknown/any) and now extend DataProvider<DataPointType>; removed direct data?: ChartData from public props.
Polar Component Props
src/polar/Pie.tsx
PieProps and InternalPieProps made generic and now extend DataProvider<DataPointType>.
Chart Component Exports
src/chart/... (AreaChart.tsx, BarChart.tsx, ComposedChart.tsx, LineChart.tsx, ScatterChart.tsx, PieChart.tsx, PolarChart.tsx, RadarChart.tsx, RadialBarChart.tsx, FunnelChart.tsx)
Added ReactNode import and adjusted public exports to generic function signatures exposing DataPointType; internal forwardRef implementations use ...Props<unknown> while default prop assertions use ...Props<never> where applicable.
Component Utilities
src/component/LabelList.tsx
Broadened dataKey type from DataKey<Record<string, unknown>> to DataKey<any>.
Storybook Examples
storybook/stories/API/chart/PieChart.stories.tsx, storybook/stories/Examples/BarChart/BarChart.stories.tsx, storybook/stories/Examples/LineChart/LineChart.stories.tsx, storybook/stories/Examples/ScatterChart.stories.tsx
Introduced local MockDataType typings for story data arrays; tightened dataKey function parameter types and added assertNotNull runtime assertions before property access.
Tests
test/chart/LineChart.spec.tsx
Test data typed as ReadonlyArray<MockDataPointType>; dataKey functions narrowed and assertNotNull added.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

typescript

Suggested reviewers

  • ckifer
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. While it identifies the purpose (adding generics to ChartData and DataProvider), it cuts off mid-sentence and lacks several required template sections including 'Motivation and Context' and 'How Has This Been Tested'. Complete the description by finishing the truncated sentence, adding 'Motivation and Context' explaining the benefits of this change, and 'How Has This Been Tested' detailing the testing approach used to validate these type changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding generic type parameters to ChartData and DataProvider types.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb77a11 and de9102d.

📒 Files selected for processing (9)
  • src/chart/AreaChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/FunnelChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/RadialBarChart.tsx
  • src/chart/ScatterChart.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/chart/RadialBarChart.tsx
  • src/chart/AreaChart.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{ts,tsx}: Never use any type (implicit or explicit) in TypeScript code
Prefer unknown over any and refine the type in TypeScript
Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions
Do not use as type assertions in TypeScript; the only exception is as const

All imports from recharts must use the public API entry point (e.g., import { TooltipIndex } from 'recharts'). Imports from internal paths like recharts/types/* or recharts/src/* are not allowed and will fail the linter.

Files:

  • src/chart/FunnelChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/ScatterChart.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Ensure code lints by running npm run lint and follows Airbnb's Style Guide

Files:

  • src/chart/FunnelChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/ScatterChart.tsx
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not hardcode any strings or formatting choices in library code; users should provide localized strings as desired

Files:

  • src/chart/FunnelChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/ScatterChart.tsx
🧠 Learnings (12)
📓 Common learnings
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6750
File: src/state/selectors/axisSelectors.ts:593-602
Timestamp: 2025-12-08T08:23:26.261Z
Learning: In the recharts codebase, `DataKey<any>` is an intentional exception to the "no any" rule while proper typing is being developed. This should not be flagged in reviews.
📚 Learning: 2026-01-06T22:34:01.675Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6855
File: www/src/docs/api/AreaChartAPI.tsx:422-438
Timestamp: 2026-01-06T22:34:01.675Z
Learning: In Recharts 3, components can render inside any chart type as long as the parent provides the necessary context. For example, Funnel can render inside AreaChart, BarChart, ComposedChart, LineChart, and ScatterChart because they all provide cartesian context. This is a change from Recharts 2, which had stricter parent-child component limitations.

Applied to files:

  • src/chart/FunnelChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/ScatterChart.tsx
📚 Learning: 2025-12-26T15:59:11.254Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-26T15:59:11.254Z
Learning: Applies to **/*.{ts,tsx} : All imports from `recharts` must use the public API entry point (e.g., `import { TooltipIndex } from 'recharts'`). Imports from internal paths like `recharts/types/*` or `recharts/src/*` are not allowed and will fail the linter.

Applied to files:

  • src/chart/FunnelChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/ScatterChart.tsx
📚 Learning: 2025-12-16T08:12:13.355Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6783
File: test/util/ChartUtils.spec.tsx:15-16
Timestamp: 2025-12-16T08:12:13.355Z
Learning: In the recharts codebase, files in the `test` folder are allowed to import from internal paths (e.g., `../../src/state/cartesianAxisSlice`) and do not need to use the public API entry point (`src/index.ts`). The public API import restriction applies only to non-test code.

Applied to files:

  • src/chart/FunnelChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/ScatterChart.tsx
📚 Learning: 2025-12-08T08:23:26.261Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6750
File: src/state/selectors/axisSelectors.ts:593-602
Timestamp: 2025-12-08T08:23:26.261Z
Learning: In the recharts codebase, `DataKey<any>` is an intentional exception to the "no any" rule while proper typing is being developed. This should not be flagged in reviews.

Applied to files:

  • src/chart/FunnelChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/ComposedChart.tsx
📚 Learning: 2025-11-23T13:30:10.395Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.395Z
Learning: The `TooltipIndex` type from recharts is defined in `src/state/tooltipSlice.ts` but is not currently exported from the public API entry points. It should not be imported from `recharts/types/state/tooltipSlice` as this is an internal implementation path. An ESLint rule is needed to prevent regressions.

Applied to files:

  • src/chart/FunnelChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/ScatterChart.tsx
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to **/*.{ts,tsx} : Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions

Applied to files:

  • src/chart/FunnelChart.tsx
  • src/chart/ComposedChart.tsx
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to **/*.{ts,tsx} : Do not use `as` type assertions in TypeScript; the only exception is `as const`

Applied to files:

  • src/chart/FunnelChart.tsx
  • src/chart/ComposedChart.tsx
📚 Learning: 2025-11-19T14:08:01.728Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6659
File: www/src/components/GuideView/Performance/index.tsx:232-250
Timestamp: 2025-11-19T14:08:01.728Z
Learning: In Recharts version 3.4.2, object-as-prop optimizations were introduced to reduce unnecessary re-renders when new object references are passed as props. This affects the recommendation for the `react-perf/jsx-no-new-object-as-prop` ESLint rule.

Applied to files:

  • src/chart/FunnelChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/ScatterChart.tsx
📚 Learning: 2025-12-14T13:58:49.197Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:49.197Z
Learning: In the recharts codebase, hooks like useAppSelector and other hooks (e.g., useChartLayout()) return undefined when used outside Redux Provider context, instead of throwing. This enables components that call these hooks, such as Curve, to operate in standalone mode by falling back to prop values. During code reviews, ensure TSX files gracefully handle undefined results from hooks and implement fallbacks (e.g., via default props or explicit prop-based values) rather than assuming the hook is always within Provider.

Applied to files:

  • src/chart/FunnelChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/ScatterChart.tsx
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to **/*.{ts,tsx} : Never use `any` type (implicit or explicit) in TypeScript code

Applied to files:

  • src/chart/ComposedChart.tsx
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to **/*.{ts,tsx} : Prefer `unknown` over `any` and refine the type in TypeScript

Applied to files:

  • src/chart/ComposedChart.tsx
🧬 Code graph analysis (7)
src/chart/FunnelChart.tsx (2)
src/index.ts (1)
  • FunnelChart (129-129)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
src/chart/PieChart.tsx (1)
src/util/types.ts (1)
  • PolarChartProps (1457-1516)
src/chart/BarChart.tsx (1)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
src/chart/RadarChart.tsx (1)
src/util/types.ts (1)
  • PolarChartProps (1457-1516)
src/chart/LineChart.tsx (1)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
src/chart/ComposedChart.tsx (1)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
src/chart/ScatterChart.tsx (1)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build, Test, Pack
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (10)
src/chart/LineChart.tsx (1)

14-16: LGTM! Generic type annotation pattern is correctly applied.

The explicit type annotation approach properly exposes the DataPointType generic to consumers while avoiding the as type assertion. The internal implementation correctly uses CartesianChartProps<unknown> for runtime type safety.

src/chart/PieChart.tsx (2)

15-15: LGTM! Appropriate use of as const satisfies.

Using as const satisfies Partial<PolarChartProps<never>> is appropriate here—as const is the allowed exception to the no-assertions rule, and never correctly indicates that the default props don't depend on any specific data point type.


22-24: LGTM! Generic type annotation correctly applied for polar chart.

The pattern is consistent with the cartesian chart components, appropriately using PolarChartProps<DataPointType> for the public API and PolarChartProps<unknown> for the internal implementation.

src/chart/ScatterChart.tsx (1)

14-16: LGTM! Consistent generic type annotation pattern.

The implementation follows the same pattern as other cartesian chart components, properly exposing DataPointType through explicit type annotation.

src/chart/BarChart.tsx (2)

2-2: No comment.


14-16: Public API update looks consistent.

No issues spotted with this export signature update.

src/chart/RadarChart.tsx (4)

2-2: No comment.


17-36: No comment.


43-45: Export signature update looks good.

No issues found with the updated RadarChart export signature.


15-15: No action needed. The repository uses TypeScript 5.7.2, which fully supports the satisfies operator (introduced in TS 4.9). The code is compatible.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/chart/PieChart.tsx (1)

22-34: Avoid as type assertion on PieChart export.

Project coding guidelines disallow as type assertions (except as const). This pattern appears in multiple chart components (AreaChart, BarChart, ComposedChart, FunnelChart, LineChart, RadarChart, RadialBarChart, ScatterChart). Consider replacing with a typed alias + assignment instead:

+type PieChartComponent = <DataPointType>(
+  props: PolarChartProps<DataPointType> & React.RefAttributes<SVGSVGElement>
+) => React.ReactElement;
+
-export const PieChart = forwardRef<SVGSVGElement, PolarChartProps<unknown>>((props: PolarChartProps<unknown>, ref) => {
+const PieChartImpl = forwardRef<SVGSVGElement, PolarChartProps<unknown>>((props: PolarChartProps<unknown>, ref) => {
   const propsWithDefaults = resolveDefaultProps(props, defaultPieChartProps);
   return (
     <PolarChart
       chartName="PieChart"
       defaultTooltipEventType="item"
       validateTooltipEventTypes={allowedTooltipTypes}
       tooltipPayloadSearcher={arrayTooltipSearcher}
       categoricalChartProps={propsWithDefaults}
       ref={ref}
     />
   );
-}) as <DataPointType>(props: PolarChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;
+});
+
+export const PieChart: PieChartComponent = PieChartImpl;
src/util/types.ts (1)

1309-1319: Add a default generic to DataProvider to prevent a type-breaking change.

DataProvider is exported and now requires a type argument; any existing DataProvider references without <T> will become errors. Defaulting to unknown preserves compatibility and aligns with ChartData's design (which is already defined as ChartData<DataPointType = unknown>).

Suggested fix
-export interface DataProvider<DataPointType> {
+export interface DataProvider<DataPointType = unknown> {
🤖 Fix all issues with AI agents
In `@src/chart/AreaChart.tsx`:
- Around line 14-29: The exported AreaChart uses an `as` type assertion to
expose a generic signature; remove the assertion and instead declare a
properly-typed generic component by making the forwarded function generic.
Concretely, replace the current forwardRef call with a generic function
component (e.g., forwardRef(function AreaChart<DataPointType>(props:
CartesianChartProps<DataPointType>, ref: React.Ref<SVGSVGElement>) { ... })) so
the generic DataPointType is part of the function signature, keep passing
categoricalChartProps={props} and ref to CartesianChart, and export that const
without using `as`.

In `@src/chart/ComposedChart.tsx`:
- Around line 14-29: Replace the "as" type assertion on ComposedChart with an
explicit generic component signature: make the forwarded component a generic
function (e.g., export const ComposedChart = forwardRef(function
ComposedChart<DataPointType>(props: CartesianChartProps<DataPointType>, ref:
React.Ref<SVGSVGElement>) { ... })) so the DataPointType generic is declared on
the function itself and no "as <...>" cast is used; keep the existing props
passed to CartesianChart (chartName, defaultTooltipEventType,
validateTooltipEventTypes, tooltipPayloadSearcher, categoricalChartProps) and
the ref wiring, and apply the same refactor pattern to the other chart
components (LineChart, AreaChart, BarChart, FunnelChart, ScatterChart, PieChart,
RadialBarChart, RadarChart) for consistency.

In `@src/chart/FunnelChart.tsx`:
- Around line 14-29: The exported FunnelChart uses an `as` type assertion for
the generic component signature which violates the no-type-assertions rule;
replace the assertion with an explicit generic type annotation on the forwarded
component export: keep the forwardRef call that returns <CartesianChart ... />
but change the export so FunnelChart is declared with a proper generic React
component type (e.g., declare FunnelChart as a generic
React.ForwardRefExoticComponent/FunctionComponent type parameterized by
DataPointType) instead of using `as <DataPointType>(...) => React.ReactElement`;
update the FunnelChart export and mirror the same change for other chart
components like LineChart/BarChart/ScatterChart to remove `as` assertions and
use explicit typed declarations around forwardRef/CartesianChart.
🧹 Nitpick comments (2)
src/cartesian/Area.tsx (1)

137-137: Consider using unknown instead of any for the default type parameter.

Other components in this PR (e.g., PieProps, CartesianChartProps, PolarChartProps) use unknown as the default generic parameter. Using any here is inconsistent and violates the coding guideline to avoid any types.

As per coding guidelines, prefer unknown over any.

♻️ Suggested change
-interface AreaProps<DataPointType = any> extends DataProvider<DataPointType>, ZIndexable {
+interface AreaProps<DataPointType = unknown> extends DataProvider<DataPointType>, ZIndexable {
src/chart/RadarChart.tsx (1)

43-57: Props type mismatch in export cast.

The component defines and uses RadarChartProps<DataPointType> internally, but the export cast on line 57 exposes PolarChartProps<DataPointType> instead. While structurally compatible, this causes the exported type to lose the RadarChart-specific JSDoc @defaultValue annotations for layout, startAngle, and endAngle.

Consider using RadarChartProps<DataPointType> in the export cast for accurate IntelliSense:

Suggested change
-) as <DataPointType>(props: PolarChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;
+) as <DataPointType>(props: RadarChartProps<DataPointType> & { ref?: React.Ref<SVGSVGElement> }) => React.ReactElement;
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b132f5a and bb77a11.

📒 Files selected for processing (23)
  • src/cartesian/Area.tsx
  • src/cartesian/Funnel.tsx
  • src/cartesian/Line.tsx
  • src/cartesian/Scatter.tsx
  • src/chart/AreaChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/FunnelChart.tsx
  • src/chart/LineChart.tsx
  • src/chart/PieChart.tsx
  • src/chart/PolarChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/RadialBarChart.tsx
  • src/chart/ScatterChart.tsx
  • src/component/LabelList.tsx
  • src/polar/Pie.tsx
  • src/state/chartDataSlice.ts
  • src/util/types.ts
  • storybook/stories/API/chart/PieChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
  • storybook/stories/Examples/ScatterChart.stories.tsx
  • test/chart/LineChart.spec.tsx
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{ts,tsx}: Never use any type (implicit or explicit) in TypeScript code
Prefer unknown over any and refine the type in TypeScript
Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions
Do not use as type assertions in TypeScript; the only exception is as const

All imports from recharts must use the public API entry point (e.g., import { TooltipIndex } from 'recharts'). Imports from internal paths like recharts/types/* or recharts/src/* are not allowed and will fail the linter.

Files:

  • src/cartesian/Funnel.tsx
  • src/chart/PolarChart.tsx
  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • test/chart/LineChart.spec.tsx
  • storybook/stories/API/chart/PieChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
  • src/cartesian/Scatter.tsx
  • src/chart/LineChart.tsx
  • src/cartesian/Area.tsx
  • src/component/LabelList.tsx
  • src/chart/AreaChart.tsx
  • src/chart/RadarChart.tsx
  • src/cartesian/Line.tsx
  • src/polar/Pie.tsx
  • src/chart/ScatterChart.tsx
  • src/chart/FunnelChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadialBarChart.tsx
  • src/util/types.ts
  • src/state/chartDataSlice.ts
  • src/chart/ComposedChart.tsx
  • src/chart/PieChart.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Ensure code lints by running npm run lint and follows Airbnb's Style Guide

Files:

  • src/cartesian/Funnel.tsx
  • src/chart/PolarChart.tsx
  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • test/chart/LineChart.spec.tsx
  • storybook/stories/API/chart/PieChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
  • src/cartesian/Scatter.tsx
  • src/chart/LineChart.tsx
  • src/cartesian/Area.tsx
  • src/component/LabelList.tsx
  • src/chart/AreaChart.tsx
  • src/chart/RadarChart.tsx
  • src/cartesian/Line.tsx
  • src/polar/Pie.tsx
  • src/chart/ScatterChart.tsx
  • src/chart/FunnelChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadialBarChart.tsx
  • src/util/types.ts
  • src/state/chartDataSlice.ts
  • src/chart/ComposedChart.tsx
  • src/chart/PieChart.tsx
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not hardcode any strings or formatting choices in library code; users should provide localized strings as desired

Files:

  • src/cartesian/Funnel.tsx
  • src/chart/PolarChart.tsx
  • src/cartesian/Scatter.tsx
  • src/chart/LineChart.tsx
  • src/cartesian/Area.tsx
  • src/component/LabelList.tsx
  • src/chart/AreaChart.tsx
  • src/chart/RadarChart.tsx
  • src/cartesian/Line.tsx
  • src/polar/Pie.tsx
  • src/chart/ScatterChart.tsx
  • src/chart/FunnelChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadialBarChart.tsx
  • src/util/types.ts
  • src/state/chartDataSlice.ts
  • src/chart/ComposedChart.tsx
  • src/chart/PieChart.tsx
storybook/stories/**/*.stories.tsx

📄 CodeRabbit inference engine (CONTRIBUTING.md)

storybook/stories/**/*.stories.tsx: Use Storybook for smoke tests and add play functions with assertions for actual tests
Update Storybook stories when APIs have been changed to ensure they work as expected

Files:

  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • storybook/stories/API/chart/PieChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
**/*.stories.{ts,tsx}

📄 CodeRabbit inference engine (DEVELOPING.md)

When adding new Storybook stories, prioritize high-fidelity examples that you want published on the website and in the Storybook UI. Use low-fidelity tests in unit tests or visual regression tests instead to avoid exceeding the Chromatic open source plan limits.

Files:

  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • storybook/stories/API/chart/PieChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
test/**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Aim for 100% unit test code coverage when writing new code

Files:

  • test/chart/LineChart.spec.tsx
test/**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (test/README.md)

test/**/*.{test,spec}.{ts,tsx}: Aim for 100% unit test code coverage when writing new code
Prefer to use the createSelectorTestCase helper function when writing or modifying tests
Use the expectLastCalledWith helper function instead of expect(spy).toHaveBeenLastCalledWith(...) for better typing and autocompletion
Verify the number of selector calls using the spy object from createSelectorTestCase to spot unnecessary re-renders and improve performance
Mock getBoundingClientRect in tests using the helper function provided in test/helper/MockGetBoundingClientRect.ts
Use vi.useFakeTimers() in all tests due to Redux autoBatchEnhancer dependency on timers and requestAnimationFrame
Call vi.runOnlyPendingTimers() to advance timers after renders when not using createSelectorTestCase helper, and avoid vi.runAllTimers() to prevent infinite loops
Use userEvent.setup({ advanceTimers: vi.runOnlyPendingTimers }) or the userEventSetup helper function from test/helper/userEventSetup.ts when creating userEvent instances
When testing tooltips on hover, use vi.runOnlyPendingTimers() after each userEvent.hover() call or use the showTooltip helper function from tooltipTestHelpers.ts to account for requestAnimationFrame delays

Files:

  • test/chart/LineChart.spec.tsx
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

When running unit tests, prefer to run a single test file using npm run test -- path/to/TestFile.spec.tsx rather than running all tests with npm test

Unit tests should be placed in the test directory, with some tests also allowed in www/test. Test files follow the naming convention *.spec.tsx.

Files:

  • test/chart/LineChart.spec.tsx
🧠 Learnings (19)
📓 Common learnings
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6750
File: src/state/selectors/axisSelectors.ts:593-602
Timestamp: 2025-12-08T08:23:26.261Z
Learning: In the recharts codebase, `DataKey<any>` is an intentional exception to the "no any" rule while proper typing is being developed. This should not be flagged in reviews.
📚 Learning: 2026-01-06T22:34:01.675Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6855
File: www/src/docs/api/AreaChartAPI.tsx:422-438
Timestamp: 2026-01-06T22:34:01.675Z
Learning: In Recharts 3, components can render inside any chart type as long as the parent provides the necessary context. For example, Funnel can render inside AreaChart, BarChart, ComposedChart, LineChart, and ScatterChart because they all provide cartesian context. This is a change from Recharts 2, which had stricter parent-child component limitations.

Applied to files:

  • src/cartesian/Funnel.tsx
  • src/chart/PolarChart.tsx
  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
  • src/chart/LineChart.tsx
  • src/chart/AreaChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/ScatterChart.tsx
  • src/chart/FunnelChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadialBarChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/PieChart.tsx
📚 Learning: 2025-12-14T13:58:49.197Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:49.197Z
Learning: In the recharts codebase, hooks like useAppSelector and other hooks (e.g., useChartLayout()) return undefined when used outside Redux Provider context, instead of throwing. This enables components that call these hooks, such as Curve, to operate in standalone mode by falling back to prop values. During code reviews, ensure TSX files gracefully handle undefined results from hooks and implement fallbacks (e.g., via default props or explicit prop-based values) rather than assuming the hook is always within Provider.

Applied to files:

  • src/cartesian/Funnel.tsx
  • src/chart/PolarChart.tsx
  • src/cartesian/Scatter.tsx
  • src/chart/LineChart.tsx
  • src/cartesian/Area.tsx
  • src/component/LabelList.tsx
  • src/chart/AreaChart.tsx
  • src/chart/RadarChart.tsx
  • src/cartesian/Line.tsx
  • src/polar/Pie.tsx
  • src/chart/ScatterChart.tsx
  • src/chart/FunnelChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadialBarChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/PieChart.tsx
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to storybook/stories/**/*.stories.tsx : Update Storybook stories when APIs have been changed to ensure they work as expected

Applied to files:

  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • storybook/stories/API/chart/PieChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to storybook/stories/**/*.stories.tsx : Use Storybook for smoke tests and add play functions with assertions for actual tests

Applied to files:

  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • storybook/stories/API/chart/PieChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
📚 Learning: 2025-12-26T15:59:11.254Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-26T15:59:11.254Z
Learning: Applies to **/*.stories.{ts,tsx} : When adding new Storybook stories, prioritize high-fidelity examples that you want published on the website and in the Storybook UI. Use low-fidelity tests in unit tests or visual regression tests instead to avoid exceeding the Chromatic open source plan limits.

Applied to files:

  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
📚 Learning: 2025-12-16T08:12:13.355Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6783
File: test/util/ChartUtils.spec.tsx:15-16
Timestamp: 2025-12-16T08:12:13.355Z
Learning: In the recharts codebase, files in the `test` folder are allowed to import from internal paths (e.g., `../../src/state/cartesianAxisSlice`) and do not need to use the public API entry point (`src/index.ts`). The public API import restriction applies only to non-test code.

Applied to files:

  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • storybook/stories/API/chart/PieChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
  • src/chart/LineChart.tsx
  • src/cartesian/Area.tsx
  • src/chart/AreaChart.tsx
  • src/chart/ScatterChart.tsx
  • src/chart/BarChart.tsx
📚 Learning: 2025-12-14T13:58:58.361Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:58.361Z
Learning: In the recharts codebase, `useAppSelector` and hooks like `useChartLayout()` are designed to return `undefined` when used outside Redux Provider context, rather than throwing errors. This allows components like `Curve` that call these hooks to work standalone by falling back to prop values.

Applied to files:

  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
📚 Learning: 2025-12-08T08:23:26.261Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6750
File: src/state/selectors/axisSelectors.ts:593-602
Timestamp: 2025-12-08T08:23:26.261Z
Learning: In the recharts codebase, `DataKey<any>` is an intentional exception to the "no any" rule while proper typing is being developed. This should not be flagged in reviews.

Applied to files:

  • storybook/stories/Examples/ScatterChart.stories.tsx
  • storybook/stories/Examples/BarChart/BarChart.stories.tsx
  • test/chart/LineChart.spec.tsx
  • storybook/stories/API/chart/PieChart.stories.tsx
  • storybook/stories/Examples/LineChart/LineChart.stories.tsx
  • src/component/LabelList.tsx
  • src/chart/AreaChart.tsx
  • src/chart/BarChart.tsx
  • src/util/types.ts
  • src/state/chartDataSlice.ts
  • src/chart/ComposedChart.tsx
📚 Learning: 2025-12-16T08:12:06.809Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6783
File: test/util/ChartUtils.spec.tsx:15-16
Timestamp: 2025-12-16T08:12:06.809Z
Learning: In tests (files under any test directory, e.g., test/, __tests__/, etc.), allow importing internal module paths (e.g., ../../src/...) and do not require imports to use the public API entry point (src/index.ts). The public API import restriction should apply only to non-test code. During reviews, accept internal imports in test files and enforce the public API pattern only for non-test code.

Applied to files:

  • test/chart/LineChart.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Mock `getBoundingClientRect` in tests using the helper function provided in `test/helper/MockGetBoundingClientRect.ts`

Applied to files:

  • test/chart/LineChart.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Use the `expectLastCalledWith` helper function instead of `expect(spy).toHaveBeenLastCalledWith(...)` for better typing and autocompletion

Applied to files:

  • test/chart/LineChart.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Verify the number of selector calls using the spy object from `createSelectorTestCase` to spot unnecessary re-renders and improve performance

Applied to files:

  • test/chart/LineChart.spec.tsx
📚 Learning: 2025-12-26T15:59:11.254Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-26T15:59:11.254Z
Learning: Applies to **/*.{ts,tsx} : All imports from `recharts` must use the public API entry point (e.g., `import { TooltipIndex } from 'recharts'`). Imports from internal paths like `recharts/types/*` or `recharts/src/*` are not allowed and will fail the linter.

Applied to files:

  • test/chart/LineChart.spec.tsx
  • src/chart/LineChart.tsx
  • src/cartesian/Area.tsx
  • src/chart/AreaChart.tsx
  • src/chart/RadarChart.tsx
  • src/polar/Pie.tsx
  • src/chart/ScatterChart.tsx
  • src/chart/BarChart.tsx
  • src/chart/RadialBarChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/PieChart.tsx
📚 Learning: 2025-11-23T13:30:10.395Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.395Z
Learning: The `TooltipIndex` type from recharts is defined in `src/state/tooltipSlice.ts` but is not currently exported from the public API entry points. It should not be imported from `recharts/types/state/tooltipSlice` as this is an internal implementation path. An ESLint rule is needed to prevent regressions.

Applied to files:

  • test/chart/LineChart.spec.tsx
  • storybook/stories/API/chart/PieChart.stories.tsx
  • src/polar/Pie.tsx
  • src/state/chartDataSlice.ts
  • src/chart/PieChart.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Prefer to use the `createSelectorTestCase` helper function when writing or modifying tests

Applied to files:

  • test/chart/LineChart.spec.tsx
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Use `vi.useFakeTimers()` in all tests due to Redux autoBatchEnhancer dependency on timers and `requestAnimationFrame`

Applied to files:

  • test/chart/LineChart.spec.tsx
📚 Learning: 2025-11-19T14:08:01.728Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6659
File: www/src/components/GuideView/Performance/index.tsx:232-250
Timestamp: 2025-11-19T14:08:01.728Z
Learning: In Recharts version 3.4.2, object-as-prop optimizations were introduced to reduce unnecessary re-renders when new object references are passed as props. This affects the recommendation for the `react-perf/jsx-no-new-object-as-prop` ESLint rule.

Applied to files:

  • src/chart/LineChart.tsx
  • src/chart/RadarChart.tsx
  • src/chart/RadialBarChart.tsx
  • src/chart/ComposedChart.tsx
  • src/chart/PieChart.tsx
📚 Learning: 2025-11-25T01:22:59.729Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-25T01:22:59.729Z
Learning: Applies to **/*.{ts,tsx} : Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions

Applied to files:

  • src/chart/LineChart.tsx
🧬 Code graph analysis (22)
src/cartesian/Funnel.tsx (1)
src/util/types.ts (1)
  • DataProvider (1309-1320)
src/chart/PolarChart.tsx (1)
src/util/types.ts (1)
  • PolarChartProps (1457-1516)
storybook/stories/Examples/ScatterChart.stories.tsx (1)
test/helper/assertNotNull.ts (1)
  • assertNotNull (1-5)
storybook/stories/Examples/BarChart/BarChart.stories.tsx (1)
test/helper/assertNotNull.ts (1)
  • assertNotNull (1-5)
test/chart/LineChart.spec.tsx (1)
test/helper/assertNotNull.ts (1)
  • assertNotNull (1-5)
storybook/stories/API/chart/PieChart.stories.tsx (1)
test/helper/assertNotNull.ts (1)
  • assertNotNull (1-5)
storybook/stories/Examples/LineChart/LineChart.stories.tsx (1)
test/helper/assertNotNull.ts (1)
  • assertNotNull (1-5)
src/cartesian/Scatter.tsx (2)
src/util/types.ts (1)
  • DataProvider (1309-1320)
src/zIndex/ZIndexLayer.tsx (1)
  • ZIndexable (14-26)
src/chart/LineChart.tsx (3)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
src/chart/CartesianChart.tsx (1)
  • CartesianChart (40-82)
src/state/optionsSlice.ts (1)
  • arrayTooltipSearcher (30-41)
src/cartesian/Area.tsx (2)
src/util/types.ts (1)
  • DataProvider (1309-1320)
src/zIndex/ZIndexLayer.tsx (1)
  • ZIndexable (14-26)
src/component/LabelList.tsx (2)
src/util/types.ts (1)
  • DataKey (93-93)
src/index.ts (1)
  • DataKey (136-136)
src/chart/AreaChart.tsx (3)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
src/chart/CartesianChart.tsx (1)
  • CartesianChart (40-82)
src/state/optionsSlice.ts (1)
  • arrayTooltipSearcher (30-41)
src/chart/RadarChart.tsx (4)
src/util/types.ts (1)
  • PolarChartProps (1457-1516)
src/util/resolveDefaultProps.tsx (1)
  • resolveDefaultProps (16-53)
src/chart/PolarChart.tsx (1)
  • PolarChart (65-111)
src/state/optionsSlice.ts (1)
  • arrayTooltipSearcher (30-41)
src/cartesian/Line.tsx (2)
src/util/types.ts (1)
  • DataProvider (1309-1320)
src/zIndex/ZIndexLayer.tsx (1)
  • ZIndexable (14-26)
src/polar/Pie.tsx (2)
src/util/types.ts (1)
  • DataProvider (1309-1320)
src/zIndex/ZIndexLayer.tsx (1)
  • ZIndexable (14-26)
src/chart/ScatterChart.tsx (3)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
src/chart/CartesianChart.tsx (1)
  • CartesianChart (40-82)
src/state/optionsSlice.ts (1)
  • arrayTooltipSearcher (30-41)
src/chart/FunnelChart.tsx (4)
src/index.ts (1)
  • FunnelChart (129-129)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
src/chart/CartesianChart.tsx (1)
  • CartesianChart (40-82)
src/state/optionsSlice.ts (1)
  • arrayTooltipSearcher (30-41)
src/chart/BarChart.tsx (3)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
src/chart/CartesianChart.tsx (1)
  • CartesianChart (40-82)
src/state/optionsSlice.ts (1)
  • arrayTooltipSearcher (30-41)
src/chart/RadialBarChart.tsx (4)
src/util/types.ts (1)
  • PolarChartProps (1457-1516)
src/util/resolveDefaultProps.tsx (1)
  • resolveDefaultProps (16-53)
src/chart/PolarChart.tsx (1)
  • PolarChart (65-111)
src/state/optionsSlice.ts (1)
  • arrayTooltipSearcher (30-41)
src/util/types.ts (2)
src/state/chartDataSlice.ts (1)
  • ChartData (15-15)
src/chart/types.ts (1)
  • ExternalMouseEvents (8-53)
src/chart/ComposedChart.tsx (3)
src/util/types.ts (1)
  • CartesianChartProps (1390-1455)
src/chart/CartesianChart.tsx (1)
  • CartesianChart (40-82)
src/state/optionsSlice.ts (1)
  • arrayTooltipSearcher (30-41)
src/chart/PieChart.tsx (1)
src/util/types.ts (1)
  • PolarChartProps (1457-1516)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build, Test, Pack
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (23)
src/component/LabelList.tsx (1)

80-80: Type widening for dataKey looks appropriate.
This aligns with the new generic data-point direction and should reduce friction across chart types.

src/state/chartDataSlice.ts (1)

15-15: ChartData generic looks good.

Defaulting to unknown keeps the type safe without forcing callers to specify a type.

src/chart/PieChart.tsx (1)

15-15: Default props typing is solid.

Using satisfies with never keeps the defaults tight and intention-revealing.

storybook/stories/Examples/BarChart/BarChart.stories.tsx (1)

24-24: Nice typing + null-safety in dataKey handlers.

The MockDataType and assertNotNull guards make the story data access explicit and safe.

Also applies to: 991-1013

storybook/stories/API/chart/PieChart.stories.tsx (1)

7-7: Good update to typed mock data and guards.

This keeps the story aligned with the new generic data typing and avoids unsafe property access.

Also applies to: 74-97

storybook/stories/Examples/ScatterChart.stories.tsx (1)

20-20: Typed mock data + guard checks look good.

Clear data shapes and runtime checks make this story safer and easier to maintain.

Also applies to: 156-174

storybook/stories/Examples/LineChart/LineChart.stories.tsx (1)

1042-1064: LGTM! Well-structured type refinements for dataKey functions.

The changes correctly introduce a local MockDataType with optional x and y properties, and use assertNotNull guards before accessing nested values. This aligns with the PR's goal of stronger type safety through generic DataPointType parameters.

The pattern of defining explicit data types and using runtime guards for optional nested properties is a good practice that catches data shape issues early during development.

src/cartesian/Funnel.tsx (1)

76-76: LGTM! Generic type parameter correctly added to FunnelProps.

The interface now extends DataProvider<DataPointType> with a sensible unknown default, aligning with the PR's broader type safety improvements and the coding guidelines that prefer unknown over any.

test/chart/LineChart.spec.tsx (1)

1805-1827: LGTM! Type safety improvements for dataKey function tests.

The changes mirror the storybook story updates with a well-defined MockDataPointType and appropriate assertNotNull guards. This strengthens the test's type coverage and documents the expected data shape explicitly.

src/cartesian/Scatter.tsx (1)

171-171: LGTM! Generic type parameter correctly added to ScatterProps.

The interface now extends DataProvider<DataPointType> with an unknown default while maintaining the ZIndexable extension. This is consistent with the pattern used across other chart components in this PR.

src/cartesian/Line.tsx (2)

35-35: LGTM! Required import added for DataProvider.

The import is necessary to support the updated LineProps interface that now extends DataProvider<DataPointType>.


127-127: LGTM! Generic type parameter correctly added to LineProps.

The interface now extends DataProvider<DataPointType> with an unknown default while maintaining the ZIndexable extension. This follows the consistent pattern established across Funnel, Scatter, and other chart components in this PR.

src/chart/PolarChart.tsx (1)

33-33: LGTM! Using never for default props is correct.

The never type parameter is appropriate here since defaultPolarChartProps doesn't include a data property. This makes the defaults compatible with any DataPointType that consumers might use.

src/polar/Pie.tsx (2)

190-190: LGTM! Generic propagation through DataProvider is correct.

The InternalPieProps interface correctly extends DataProvider<DataPointType> with a default of unknown, which aligns with the type safety improvements across the codebase.


222-222: LGTM! PieProps generic signature is consistent.

The public PieProps interface mirrors the InternalPieProps pattern, extending DataProvider<DataPointType> with unknown as the default. This maintains consistency between internal and external prop interfaces.

src/cartesian/Area.tsx (1)

37-37: LGTM! DataProvider import added.

The import of DataProvider is correctly added to support the generic typing for the data prop.

src/chart/BarChart.tsx (1)

14-29: LGTM! Generic chart pattern correctly implemented.

The pattern of using forwardRef with CartesianChartProps<unknown> internally, then casting to a generic function signature, is the standard approach for creating generic React components with forwardRef. The type cast at line 27-29 is a necessary workaround for React's typing limitations and is consistent with other chart components in this PR.

src/chart/LineChart.tsx (1)

14-29: LGTM! Consistent generic pattern with other chart components.

The implementation follows the same pattern as BarChart and other chart components in this PR, maintaining consistency across the codebase. The generic type cast enables consumers to specify their data point type while keeping internal typing safe with unknown.

src/chart/ScatterChart.tsx (1)

14-29: The suggested fix is syntactically invalid TypeScript. The as <DataPointType>(...) pattern is a necessary workaround in this codebase to expose generic type parameters on forwardRef components—React.forwardRef does not preserve generics by default. This pattern appears intentionally across 9 chart components and the codebase builds successfully.

If strict adherence to the "no as assertions" guideline is required, this pattern needs either: (a) documentation as a required exception for generic forwardRef components, or (b) refactoring to an alternative approach (e.g., wrapper components or higher-order components). The current proposed fix is not a valid alternative.

src/chart/RadarChart.tsx (2)

15-15: LGTM on the never type parameter for default props.

Using never ensures the default props object cannot accidentally contain data-point-specific values, which is the correct approach for static defaults that will be merged with user-provided typed props at runtime.


17-36: LGTM on the generic type definition.

The RadarChartProps<DataPointType> type correctly omits the properties with different defaults from PolarChartProps and re-declares them with RadarChart-specific JSDoc documentation and default values.

src/chart/RadialBarChart.tsx (2)

10-15: LGTM on the default props typing.

Using Partial<PolarChartProps<never>> ensures type-safe defaults without data-point-specific values.


22-36: LGTM on the generic component implementation.

The component correctly:

  • Uses PolarChartProps<unknown> internally for the forwardRef signature
  • Applies resolveDefaultProps to merge user props with defaults
  • Exports a generic signature via the type cast, enabling consumers to specify their data point type

This pattern is consistent with the other chart components in this PR.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread src/chart/AreaChart.tsx
Comment thread src/chart/ComposedChart.tsx
Comment thread src/chart/FunnelChart.tsx
@codecov

codecov Bot commented Jan 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.28%. Comparing base (b132f5a) to head (de9102d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6896   +/-   ##
=======================================
  Coverage   94.27%   94.28%           
=======================================
  Files         565      565           
  Lines       53858    53867    +9     
  Branches     5178     5178           
=======================================
+ Hits        50777    50786    +9     
  Misses       3072     3072           
  Partials        9        9           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

Staging Deployment Details

These deployments will remain available for 30 days.

To update snapshots: Comment /update-snapshots on this PR to automatically update the baseline screenshots.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Staging Deployment Details

These deployments will remain available for 30 days.

To update snapshots: Comment /update-snapshots on this PR to automatically update the baseline screenshots.

@github-actions

Copy link
Copy Markdown
Contributor

Staging Deployment Details

These deployments will remain available for 30 days.

To update snapshots: Comment /update-snapshots on this PR to automatically update the baseline screenshots.

@codecov

codecov Bot commented Jan 17, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@ckifer
ckifer merged commit 8047386 into main Jan 26, 2026
120 of 121 checks passed
@ckifer
ckifer deleted the DataPointType branch January 26, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants