Skip to content

More undefined checks#6826

Merged
ckifer merged 1 commit intomainfrom
ts-strict
Dec 26, 2025
Merged

More undefined checks#6826
ckifer merged 1 commit intomainfrom
ts-strict

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Dec 26, 2025

Related Issue

#6645

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced null/undefined safety across scatter plots, treemaps, and rectangles with proper guards and optional chaining
    • Improved array type checks and safer index access patterns
  • Refactoring

    • Consolidated bar positioning logic into a centralized combiner function
    • Restructured middleware with stronger type annotations
    • Renamed and reorganized axis settings selectors for consistency
    • Simplified radial bar axis selector signatures
  • Tests

    • Updated test cases to reflect restructured selector names and simplified function signatures

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 26, 2025

Walkthrough

This PR refactors selector APIs and improves type safety across the state management layer. Key changes include renaming selectAxisSettings to selectRenderableAxisSettings, introducing a new combineBarPosition combiner, adding generic type parameters to middleware, updating optional parameter handling in scatter and radial bar selectors, and updating related snapshot and test files.

Changes

Cohort / File(s) Summary
Snapshot files
scripts/snapshots/es6Files.txt, scripts/snapshots/libFiles.txt, scripts/snapshots/typesFiles.txt
Added combineBarPosition module paths to snapshot lists for es6, lib, and type declaration exports.
Middleware type safety
src/state/externalEventsMiddleware.ts, src/state/keyboardEventsMiddleware.ts, src/state/mouseEventsMiddleware.ts
Updated middleware to use generic type parameter RechartsRootState in createListenerMiddleware<RechartsRootState>() for improved type inference.
Axis selector refactoring
src/state/selectors/axisSelectors.ts
Renamed selectAxisSettings to selectRenderableAxisSettings; updated scale type handling from ScaleType to D3ScaleType; broadened categorical domain types from CategoricalDomainItem to unknown; updated dependent selectors.
Bar selector updates
src/state/selectors/barSelectors.ts, src/state/selectors/combiners/combineBarPosition.ts
Created new combineBarPosition combiner; delegated selectBarPosition to use it; narrowed return types for selectBarSizeList and selectBarBandSize to remove undefined; broadened parameter types to allow undefined.
Bar size/position combiners
src/state/selectors/combiners/combineBarSizeList.ts, src/state/selectors/combiners/combineAllBarPositions.ts
Widened globalSize parameter types to include string; hardened null-safety for array access with optional chaining; expanded parameter optionality for bandSize and globalMaxBarSize.
Stacked data combiner
src/state/selectors/combiners/combineStackedData.ts
Typed stackGroup to allow undefined to reflect potential missing entries.
Scatter selectors
src/state/selectors/scatterSelectors.ts, src/cartesian/Scatter.tsx
Updated selectZAxis to return `ZAxisWithScale
Radial bar selectors
src/state/selectors/radialBarSelectors.ts
Removed isPanorama parameters from axis tick selectors; integrated combineBarPosition for position lookup; widened parameter optionality throughout; tightened return types; added undefined checks for dependent objects.
Polar and container selectors
src/state/selectors/polarSelectors.ts, src/state/selectors/polarScaleSelectors.ts, src/state/selectors/containerSelectors.ts, src/state/selectors/areaSelectors.ts
Updated to use selectRenderableAxisSettings; narrowed selectPolarDisplayedData return type; updated dependency declarations.
Pie and root prop selectors
src/state/selectors/pieSelectors.ts, src/state/selectors/rootPropsSelectors.ts
Made cells parameter optional in pie selectors; narrowed selectBarGap return type from string | number | undefined to string | number.
Slice and axis state
src/state/cartesianAxisSlice.ts, src/state/polarOptionsSlice.ts
Added nullish coalescing in axis width comparison; refactored polarOptionsSlice with explicit state typing and separate reducers object; exported new polarOptionsReducer.
Chart components
src/cartesian/Scatter.tsx, src/chart/Treemap.tsx, src/shape/Rectangle.tsx
Added null-checks and optional chaining for nullable children/ticks; replaced radius instanceof Array with Array.isArray(radius); introduced nullish coalescing for safe element access.
Utility updates
src/util/ChartUtils.ts
Updated getCateCoordinateOfLine ticks parameter from Array<TickItem> to ReadonlyArray<TickItem> | undefined with optional chaining access.
Test files
test/cartesian/XAxis/XAxis.state.spec.tsx, test/cartesian/XAxis/XAxis.vertical.spec.tsx, test/cartesian/YAxis/YAxis.spec.tsx, test/cartesian/YAxis/YAxis.ticks.spec.tsx, test/chart/RadialBarChart.5966.spec.tsx, test/polar/RadialBar.spec.tsx
Updated test imports and calls to use selectRenderableAxisSettings instead of selectAxisSettings; adjusted radial bar selector calls to reflect removed parameters.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

typescript, refactor

Suggested reviewers

  • ckifer

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description only includes a related issue link without any substantive details about the changes, motivation, testing, or implementation approach required by the template. Complete the PR description by adding sections for Motivation and Context, How Has This Been Tested, and Types of changes to provide reviewers with necessary context.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'More undefined checks' is vague and uses a generic term that doesn't convey the specific nature or scope of the changes made in the PR. Consider using a more descriptive title that specifies the primary change, such as 'Add optional parameter handling across multiple selectors and utilities' or 'Make optional/undefined parameters in axis and bar position selectors'.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ts-strict

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

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

⚠️ Outside diff range comments (1)
src/state/selectors/combiners/combineAllBarPositions.ts (1)

105-111: Type error: bandSize may be undefined when passed to getBarPositions.

The ternary operator barBandSize !== bandSize ? barBandSize : bandSize can return bandSize when the condition is false, but bandSize has type number | undefined. Since getBarPositions at line 10 expects bandSize: number, TypeScript will report a type error. Consider adding a null coalesce operator or explicit type guard: barBandSize !== bandSize ? barBandSize : (bandSize ?? 0).

🧹 Nitpick comments (3)
src/state/selectors/scatterSelectors.ts (1)

128-155: LGTM! Parameter types and guards correctly handle optional data.

The optional types align with the signature changes in computeScatterPoints, and the guard clauses properly validate required parameters while allowing zAxis to be optional.

Minor: Optional chaining is redundant after explicit null checks

Lines 151-152 use optional chaining (xAxisTicks?.length, yAxisTicks?.length) after explicit null checks on lines 149-150. While harmless, this is redundant:

  if (
    displayedData == null ||
    xAxis == null ||
    yAxis == null ||
    xAxisTicks == null ||
    yAxisTicks == null ||
-   xAxisTicks?.length === 0 ||
-   yAxisTicks?.length === 0
+   xAxisTicks.length === 0 ||
+   yAxisTicks.length === 0
  ) {
src/util/ChartUtils.ts (1)

517-535: Remove the line 528 runtime error concern — findEntryInArray safely handles undefined arrays.

The function findEntryInArray includes an early return guard (if (!ary || !ary.length) { return undefined; }) that safely handles undefined inputs. Passing ticks when it's undefined will not cause a runtime error; the function will simply return undefined, which is the intended behavior. This aligns with the PR's goal of adding undefined checks.

Note: There is a TypeScript type mismatch here — ticks is typed as ReadonlyArray<TickItem> | undefined, but findEntryInArray expects ReadonlyArray<T> (not optional). At runtime this works fine due to the guard check, but TypeScript may flag this type incompatibility depending on strictness settings.

Optional: Cleaner pattern for line 535.

Line 535 accesses ticks[index] twice in the expression ticks?.[index] ? ticks[index].coordinate + bandSize / 2 : null. Consider storing the result in an intermediate variable for clarity:

const tick = ticks?.[index];
return tick ? tick.coordinate + bandSize / 2 : null;
src/state/selectors/axisSelectors.ts (1)

1855-1857: The ts-expect-error suggests potential dead code.

The comment indicates that comparing realScaleType === 'scaleBand' may never be true because band axes report their type as 'band', not 'scaleBand'. Consider investigating whether this condition can be removed or the comparison corrected.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d52345f and eafee34.

📒 Files selected for processing (32)
  • scripts/snapshots/es6Files.txt
  • scripts/snapshots/libFiles.txt
  • scripts/snapshots/typesFiles.txt
  • src/cartesian/Scatter.tsx
  • src/chart/Treemap.tsx
  • src/shape/Rectangle.tsx
  • src/state/cartesianAxisSlice.ts
  • src/state/externalEventsMiddleware.ts
  • src/state/keyboardEventsMiddleware.ts
  • src/state/mouseEventsMiddleware.ts
  • src/state/polarOptionsSlice.ts
  • src/state/selectors/areaSelectors.ts
  • src/state/selectors/axisSelectors.ts
  • src/state/selectors/barSelectors.ts
  • src/state/selectors/combiners/combineAllBarPositions.ts
  • src/state/selectors/combiners/combineBarPosition.ts
  • src/state/selectors/combiners/combineBarSizeList.ts
  • src/state/selectors/combiners/combineStackedData.ts
  • src/state/selectors/containerSelectors.ts
  • src/state/selectors/pieSelectors.ts
  • src/state/selectors/polarScaleSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/radialBarSelectors.ts
  • src/state/selectors/rootPropsSelectors.ts
  • src/state/selectors/scatterSelectors.ts
  • src/util/ChartUtils.ts
  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/chart/RadialBarChart.5966.spec.tsx
  • test/polar/RadialBar.spec.tsx
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{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

Files:

  • src/state/selectors/rootPropsSelectors.ts
  • src/chart/Treemap.tsx
  • src/state/keyboardEventsMiddleware.ts
  • src/state/mouseEventsMiddleware.ts
  • src/state/selectors/combiners/combineBarPosition.ts
  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • src/state/selectors/combiners/combineAllBarPositions.ts
  • src/state/cartesianAxisSlice.ts
  • src/state/polarOptionsSlice.ts
  • src/cartesian/Scatter.tsx
  • src/shape/Rectangle.tsx
  • src/state/selectors/barSelectors.ts
  • src/state/selectors/containerSelectors.ts
  • src/state/selectors/combiners/combineBarSizeList.ts
  • src/state/selectors/combiners/combineStackedData.ts
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • src/state/selectors/scatterSelectors.ts
  • src/util/ChartUtils.ts
  • src/state/externalEventsMiddleware.ts
  • test/chart/RadialBarChart.5966.spec.tsx
  • src/state/selectors/areaSelectors.ts
  • src/state/selectors/polarScaleSelectors.ts
  • src/state/selectors/radialBarSelectors.ts
  • src/state/selectors/pieSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/axisSelectors.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

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

Files:

  • src/state/selectors/rootPropsSelectors.ts
  • src/chart/Treemap.tsx
  • src/state/keyboardEventsMiddleware.ts
  • src/state/mouseEventsMiddleware.ts
  • src/state/selectors/combiners/combineBarPosition.ts
  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • src/state/selectors/combiners/combineAllBarPositions.ts
  • src/state/cartesianAxisSlice.ts
  • src/state/polarOptionsSlice.ts
  • src/cartesian/Scatter.tsx
  • src/shape/Rectangle.tsx
  • src/state/selectors/barSelectors.ts
  • src/state/selectors/containerSelectors.ts
  • src/state/selectors/combiners/combineBarSizeList.ts
  • src/state/selectors/combiners/combineStackedData.ts
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • src/state/selectors/scatterSelectors.ts
  • src/util/ChartUtils.ts
  • src/state/externalEventsMiddleware.ts
  • test/chart/RadialBarChart.5966.spec.tsx
  • src/state/selectors/areaSelectors.ts
  • src/state/selectors/polarScaleSelectors.ts
  • src/state/selectors/radialBarSelectors.ts
  • src/state/selectors/pieSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/axisSelectors.ts
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/state/selectors/rootPropsSelectors.ts
  • src/chart/Treemap.tsx
  • src/state/keyboardEventsMiddleware.ts
  • src/state/mouseEventsMiddleware.ts
  • src/state/selectors/combiners/combineBarPosition.ts
  • src/state/selectors/combiners/combineAllBarPositions.ts
  • src/state/cartesianAxisSlice.ts
  • src/state/polarOptionsSlice.ts
  • src/cartesian/Scatter.tsx
  • src/shape/Rectangle.tsx
  • src/state/selectors/barSelectors.ts
  • src/state/selectors/containerSelectors.ts
  • src/state/selectors/combiners/combineBarSizeList.ts
  • src/state/selectors/combiners/combineStackedData.ts
  • src/state/selectors/scatterSelectors.ts
  • src/util/ChartUtils.ts
  • src/state/externalEventsMiddleware.ts
  • src/state/selectors/areaSelectors.ts
  • src/state/selectors/polarScaleSelectors.ts
  • src/state/selectors/radialBarSelectors.ts
  • src/state/selectors/pieSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/axisSelectors.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (DEVELOPING.md)

All imports from recharts must use the public API entry point; imports from internal paths like recharts/types/* or recharts/src/* are not allowed

Files:

  • src/state/selectors/rootPropsSelectors.ts
  • src/chart/Treemap.tsx
  • src/state/keyboardEventsMiddleware.ts
  • src/state/mouseEventsMiddleware.ts
  • src/state/selectors/combiners/combineBarPosition.ts
  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • src/state/selectors/combiners/combineAllBarPositions.ts
  • src/state/cartesianAxisSlice.ts
  • src/state/polarOptionsSlice.ts
  • src/cartesian/Scatter.tsx
  • src/shape/Rectangle.tsx
  • src/state/selectors/barSelectors.ts
  • src/state/selectors/containerSelectors.ts
  • src/state/selectors/combiners/combineBarSizeList.ts
  • src/state/selectors/combiners/combineStackedData.ts
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • src/state/selectors/scatterSelectors.ts
  • src/util/ChartUtils.ts
  • src/state/externalEventsMiddleware.ts
  • test/chart/RadialBarChart.5966.spec.tsx
  • src/state/selectors/areaSelectors.ts
  • src/state/selectors/polarScaleSelectors.ts
  • src/state/selectors/radialBarSelectors.ts
  • src/state/selectors/pieSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/axisSelectors.ts
test/**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

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

Files:

  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/chart/RadialBarChart.5966.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/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/chart/RadialBarChart.5966.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

Files:

  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/chart/RadialBarChart.5966.spec.tsx
🧠 Learnings (16)
📓 Common learnings
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
📚 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/state/selectors/rootPropsSelectors.ts
  • src/state/keyboardEventsMiddleware.ts
  • src/state/mouseEventsMiddleware.ts
  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • scripts/snapshots/typesFiles.txt
  • src/state/polarOptionsSlice.ts
  • src/cartesian/Scatter.tsx
  • src/state/selectors/barSelectors.ts
  • src/state/selectors/scatterSelectors.ts
  • src/state/externalEventsMiddleware.ts
  • test/chart/RadialBarChart.5966.spec.tsx
  • src/state/selectors/pieSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/axisSelectors.ts
📚 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:

  • src/state/selectors/rootPropsSelectors.ts
  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • src/state/selectors/barSelectors.ts
  • src/state/selectors/containerSelectors.ts
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • src/state/selectors/scatterSelectors.ts
  • src/state/selectors/polarScaleSelectors.ts
  • src/state/selectors/radialBarSelectors.ts
  • src/state/selectors/pieSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/axisSelectors.ts
📚 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/state/selectors/rootPropsSelectors.ts
  • src/chart/Treemap.tsx
  • scripts/snapshots/libFiles.txt
  • scripts/snapshots/typesFiles.txt
  • src/state/selectors/barSelectors.ts
  • scripts/snapshots/es6Files.txt
  • src/state/selectors/scatterSelectors.ts
  • src/state/selectors/radialBarSelectors.ts
  • src/state/selectors/polarSelectors.ts
  • src/state/selectors/axisSelectors.ts
📚 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/Treemap.tsx
  • src/cartesian/Scatter.tsx
  • src/shape/Rectangle.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/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • scripts/snapshots/es6Files.txt
  • test/chart/RadialBarChart.5966.spec.tsx
  • src/state/selectors/polarScaleSelectors.ts
  • src/state/selectors/axisSelectors.ts
📚 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/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/chart/RadialBarChart.5966.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} : Prefer to use the `createSelectorTestCase` helper function when writing or modifying tests

Applied to files:

  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/chart/RadialBarChart.5966.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} : Call `vi.runOnlyPendingTimers()` to advance timers after renders when not using `createSelectorTestCase` helper, and avoid `vi.runAllTimers()` to prevent infinite loops

Applied to files:

  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/cartesian/YAxis/YAxis.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/chart/RadialBarChart.5966.spec.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 test/component/**/*.spec.tsx : Use React Testing Library for testing component interactions and behavior upon rendering

Applied to files:

  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/cartesian/XAxis/XAxis.vertical.spec.tsx
  • test/chart/RadialBarChart.5966.spec.tsx
📚 Learning: 2025-12-06T03:36:59.377Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-06T03:36:59.377Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : All imports from `recharts` must use the public API entry point; imports from internal paths like `recharts/types/*` or `recharts/src/*` are not allowed

Applied to files:

  • test/cartesian/XAxis/XAxis.state.spec.tsx
  • src/state/selectors/barSelectors.ts
  • src/state/externalEventsMiddleware.ts
  • src/state/selectors/radialBarSelectors.ts
📚 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/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.ticks.spec.tsx
  • test/polar/RadialBar.spec.tsx
  • test/chart/RadialBarChart.5966.spec.tsx
📚 Learning: 2025-11-16T09:14:24.918Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6640
File: src/cartesian/Bar.tsx:156-159
Timestamp: 2025-11-16T09:14:24.918Z
Learning: In recharts, SSR (Server-Side Rendering) is not yet supported—charts don't render at all in SSR environments. The `isAnimationActive: 'auto'` mode is preparatory work for future SSR support, so testing of this mode should be deferred until SSR support is actually implemented.

Applied to files:

  • test/cartesian/XAxis/XAxis.state.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/cartesian/XAxis/XAxis.state.spec.tsx
  • test/cartesian/YAxis/YAxis.spec.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:

  • test/cartesian/YAxis/YAxis.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} : 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

Applied to files:

  • test/chart/RadialBarChart.5966.spec.tsx
🧬 Code graph analysis (24)
src/state/selectors/rootPropsSelectors.ts (1)
src/state/store.ts (1)
  • RechartsRootState (23-38)
src/state/keyboardEventsMiddleware.ts (1)
src/state/store.ts (1)
  • RechartsRootState (23-38)
src/state/mouseEventsMiddleware.ts (1)
src/state/store.ts (1)
  • RechartsRootState (23-38)
src/state/selectors/combiners/combineBarPosition.ts (3)
src/state/selectors/barSelectors.ts (1)
  • BarWithPosition (163-178)
src/state/types/StackedGraphicalItem.ts (1)
  • MaybeStackedGraphicalItem (9-15)
src/util/ChartUtils.ts (1)
  • BarPositionPosition (61-75)
test/cartesian/XAxis/XAxis.state.spec.tsx (2)
src/state/hooks.ts (1)
  • useAppSelector (40-50)
src/state/selectors/axisSelectors.ts (1)
  • selectRenderableAxisSettings (253-274)
test/cartesian/YAxis/YAxis.ticks.spec.tsx (1)
src/state/selectors/axisSelectors.ts (1)
  • selectRenderableAxisSettings (253-274)
src/state/selectors/combiners/combineAllBarPositions.ts (1)
src/util/isWellBehavedNumber.ts (1)
  • isWellBehavedNumber (1-3)
src/state/polarOptionsSlice.ts (1)
src/state/tooltipSlice.ts (1)
  • initialState (240-267)
src/cartesian/Scatter.tsx (3)
src/state/selectors/axisSelectors.ts (1)
  • ZAxisWithScale (2089-2089)
src/state/types/ScatterSettings.ts (1)
  • ScatterSettings (6-12)
src/util/types.ts (1)
  • TickItem (946-958)
src/shape/Rectangle.tsx (1)
storybook/stories/API/props/RectangleProps.ts (1)
  • radius (8-21)
src/state/selectors/barSelectors.ts (4)
src/state/types/BarSettings.ts (1)
  • BarSettings (5-10)
src/state/selectors/combiners/combineBarPosition.ts (1)
  • combineBarPosition (5-20)
src/state/selectors/axisSelectors.ts (1)
  • BaseAxisWithScale (2058-2058)
src/util/ChartUtils.ts (1)
  • BarPositionPosition (61-75)
src/state/selectors/combiners/combineBarSizeList.ts (1)
src/state/selectors/barSelectors.ts (1)
  • SizeList (77-77)
src/state/selectors/combiners/combineStackedData.ts (1)
src/util/stacks/stackTypes.ts (1)
  • StackGroup (32-35)
test/cartesian/YAxis/YAxis.spec.tsx (1)
src/state/selectors/axisSelectors.ts (1)
  • selectRenderableAxisSettings (253-274)
test/cartesian/XAxis/XAxis.vertical.spec.tsx (2)
src/state/hooks.ts (1)
  • useAppSelector (40-50)
src/state/selectors/axisSelectors.ts (1)
  • selectRenderableAxisSettings (253-274)
src/util/ChartUtils.ts (1)
src/util/types.ts (1)
  • TickItem (946-958)
src/state/externalEventsMiddleware.ts (1)
src/state/store.ts (1)
  • RechartsRootState (23-38)
test/chart/RadialBarChart.5966.spec.tsx (1)
src/state/selectors/radialBarSelectors.ts (1)
  • selectRadiusAxisTicks (59-64)
src/state/selectors/areaSelectors.ts (1)
src/util/stacks/stackTypes.ts (1)
  • StackSeries (43-43)
src/state/selectors/polarScaleSelectors.ts (4)
src/context/chartLayoutContext.tsx (1)
  • selectChartLayout (133-133)
src/state/selectors/polarSelectors.ts (1)
  • selectPolarAppliedValues (67-74)
src/state/selectors/axisSelectors.ts (1)
  • selectRenderableAxisSettings (253-274)
src/state/selectors/pickAxisType.ts (1)
  • pickAxisType (3-3)
src/state/selectors/radialBarSelectors.ts (6)
src/state/selectors/polarScaleSelectors.ts (2)
  • selectPolarGraphicalItemAxisTicks (124-140)
  • selectPolarAxisTicks (79-97)
src/state/selectors/axisSelectors.ts (1)
  • BaseAxisWithScale (2058-2058)
src/util/types.ts (3)
  • TickItem (946-958)
  • LayoutType (57-57)
  • PolarViewBoxRequired (992-992)
src/state/selectors/combiners/combineBarPosition.ts (1)
  • combineBarPosition (5-20)
src/state/cartesianAxisSlice.ts (1)
  • AxisId (11-11)
src/state/types/RadialBarSettings.ts (1)
  • RadialBarSettings (4-8)
src/state/selectors/pieSelectors.ts (1)
src/state/types/PieSettings.ts (1)
  • PieSettings (10-30)
src/state/selectors/polarSelectors.ts (2)
src/state/chartDataSlice.ts (1)
  • ChartData (14-14)
src/state/selectors/axisSelectors.ts (1)
  • selectRenderableAxisSettings (253-274)
src/state/selectors/axisSelectors.ts (2)
src/util/types.ts (2)
  • D3ScaleType (160-175)
  • TickItem (946-958)
src/util/scale/RechartsScale.ts (1)
  • RechartsScale (15-74)
⏰ 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 (66)
src/state/keyboardEventsMiddleware.ts (1)

16-16: LGTM: Type safety improvement.

Adding the <RechartsRootState> generic parameter enhances type inference within listener effects and aligns the middleware declaration with its usage.

src/state/externalEventsMiddleware.ts (1)

21-21: LGTM: Consistent type safety improvement.

The middleware now correctly declares its state type, matching the pattern applied across all middleware files in this PR.

src/state/mouseEventsMiddleware.ts (1)

12-12: LGTM: Type safety improvements for both middleware instances.

Both mouseClickMiddleware and mouseMoveMiddleware now correctly specify their state type, improving type inference and consistency across the codebase.

Also applies to: 34-34

src/state/selectors/combiners/combineStackedData.ts (1)

17-17: LGTM! Improved type safety.

The explicit | undefined type annotation correctly reflects that accessing stackGroups[stackId] may not return a value when the key doesn't exist. This improves type correctness and aligns with the PR's goal of adding more undefined checks.

src/state/polarOptionsSlice.ts (4)

12-14: LGTM: Type safety improvements.

The explicit PolarChartState type alias and typed initialState constant improve type safety for strict mode. The union with null correctly represents the uninitialized state.


16-20: LGTM: Reducer correctly typed with explicit return type.

The reducer is properly typed with explicit parameter and return types. The return type PolarChartOptions is narrower than the state type PolarChartState (which includes null), which correctly represents that this reducer transitions state from potentially null to a defined value. The unused _state parameter is appropriately prefixed with an underscore.


22-26: LGTM: Explicit generic types improve type safety.

The explicit generic type parameters createSlice<PolarChartState, typeof reducers> provide better type inference and compile-time type checking. This follows Redux Toolkit best practices and aligns with the PR's goal of improving type safety.


30-30: LGTM: Appropriate reducer export.

The polarOptionsReducer export follows Redux naming conventions and provides a clean public API for the slice.

src/state/selectors/pieSelectors.ts (2)

77-77: LGTM: Type annotation improves clarity.

Making the cells parameter type explicit aligns with the coding guideline to type parameters explicitly rather than relying on inference. The type correctly matches what pickCells returns, and the existing optional chaining on line 85 already handles undefined cells safely.


111-111: LGTM: Explicit typing enhances type safety.

The explicit PieSettings | undefined annotation correctly reflects the return type of selectSynchronisedPieSettings and maintains consistency with the pattern established on line 42. The undefined guard at line 115 ensures safe usage.

src/shape/Rectangle.tsx (2)

31-31: LGTM: Best practice improvement.

Using Array.isArray() instead of instanceof Array is more reliable across different execution contexts and is the recommended approach for array type checking.


34-35: LGTM: Defensive undefined handling.

The nullish coalescing operator (?? 0) appropriately handles cases where the radius array might have fewer than 4 elements at runtime, despite the tuple type definition. The explicit type annotation on r follows coding guidelines, and the intermediate variable improves readability while avoiding duplicate array access.

src/state/cartesianAxisSlice.ts (2)

205-205: Defensive type safety improvement.

The nullish coalescing operator correctly handles TypeScript's strict undefined checks. Although the history.length === 3 guard on line 201 ensures history[0] exists at runtime, TypeScript doesn't narrow array element types based on length checks. This defensive change aligns with the PR's goal of improving undefined handling.


210-214: Correct axis update pattern.

The object spread correctly preserves all properties from the current axis while updating width and widthHistory. This ensures no other axis properties are lost during the update.

src/cartesian/Scatter.tsx (3)

680-684: LGTM! Type signatures properly support optional axis data.

The parameter types correctly reflect that zAxis and tick arrays may be undefined. The function body handles these cases with appropriate guards at lines 688-689, 719, and 748.


719-730: LGTM! Proper guard for optional z-axis data.

The null check ensures z-axis data is only added to the tooltip payload when zAxis is defined, preventing undefined access.


748-748: LGTM! Safe size calculation with proper fallback.

The null check ensures zAxis.scale is only accessed when zAxis is defined, with a sensible fallback to defaultZ.

src/state/selectors/scatterSelectors.ts (2)

9-9: LGTM! Import additions support the type signature changes.

The TickItem import is required for the updated parameter types in the combiner function.

Also applies to: 18-18


60-65: LGTM! Return type correctly reflects optional z-axis.

The undefined return type properly handles cases where z-axis data is unavailable.

src/state/selectors/areaSelectors.ts (1)

124-125: LGTM! Type annotation now accurately reflects undefined possibility.

The type annotation change correctly acknowledges that stackedData can be undefined, and the code safely handles this with optional chaining on line 125.

src/chart/Treemap.tsx (4)

211-213: LGTM! Defensive null check prevents potential runtime errors.

The added null check in horizontalPosition safely skips processing when a child is null, preventing potential crashes.


248-250: LGTM! Defensive null check prevents potential runtime errors.

The added null check in verticalPosition safely skips processing when a child is null, preventing potential crashes.


301-306: LGTM! Proper null handling in squarify logic.

The code correctly checks if the first element is null before using it, then pushes the non-null child to the row. This prevents potential runtime errors when processing children.


899-901: LGTM! Proper null check for touch event.

The early return when the first touch event is null prevents potential crashes in touch handling.

scripts/snapshots/libFiles.txt (1)

142-142: LGTM! Snapshot updated for new combiner module.

The addition of lib/state/selectors/combiners/combineBarPosition.js correctly reflects the new combiner module introduced in this PR.

scripts/snapshots/es6Files.txt (1)

142-142: LGTM! ES6 snapshot updated for new combiner module.

The addition correctly reflects the new combiner module in the ES6 build output.

scripts/snapshots/typesFiles.txt (1)

142-142: LGTM! Type declarations snapshot updated for new combiner module.

The addition correctly reflects the type declaration file for the new combiner module.

src/state/selectors/polarScaleSelectors.ts (1)

9-9: LGTM! Import updated as part of selector renaming refactor.

The change from selectAxisSettings to selectRenderableAxisSettings aligns with the broader refactoring across the codebase to use more descriptive selector names.

Also applies to: 75-75

src/state/selectors/rootPropsSelectors.ts (1)

7-7: Confirm the return type correctly excludes undefined.

The barGap property is defined in UpdatableChartOptions as number | string (never optional), initialized with default value 4 in initialState, and protected by nullish coalescing in reducers. The selector's return type string | number is correct.

src/state/selectors/containerSelectors.ts (1)

10-10: No action required. The margin property in ChartLayoutState is always initialized with a default value ({ top: 5, right: 5, bottom: 5, left: 5 }) in the initial state, and the setMargin reducer only mutates individual properties—it never assigns undefined or null to margin. The return type Margin (non-nullable) is correct and safe.

Likely an incorrect or invalid review comment.

test/chart/RadialBarChart.5966.spec.tsx (1)

41-41: LGTM - Selector signature simplified.

The call to selectRadiusAxisTicks has been correctly updated to match the simplified signature shown in the relevant code snippets, removing the third and fourth parameters.

test/cartesian/YAxis/YAxis.spec.tsx (1)

27-27: LGTM - Selector renamed to selectRenderableAxisSettings.

The update from selectAxisSettings to selectRenderableAxisSettings is consistent with the project-wide refactor to use more descriptive naming for renderable axis configuration.

Also applies to: 959-959, 1024-1025

test/cartesian/XAxis/XAxis.vertical.spec.tsx (1)

6-6: LGTM - Consistent selector rename.

The change from selectAxisSettings to selectRenderableAxisSettings aligns with the refactoring in other test files.

Also applies to: 166-166

test/polar/RadialBar.spec.tsx (1)

189-189: LGTM - Selector parameter simplified.

The removal of the last boolean parameter from selectBandSizeOfPolarAxis simplifies the API while maintaining the same test expectations.

test/cartesian/XAxis/XAxis.state.spec.tsx (1)

7-11: LGTM - Selector renamed consistently.

The updates to use selectRenderableAxisSettings are consistent with the project-wide refactoring of axis selector naming.

Also applies to: 20-20, 84-85

src/state/selectors/combiners/combineBarPosition.ts (1)

1-20: LGTM - Proper undefined checks implemented.

The new combineBarPosition function correctly:

  • Uses == null to check for both null and undefined inputs (line 9)
  • Returns undefined early when inputs are missing
  • Returns undefined when no matching position is found (lines 16-18)
  • Properly matches bar positions by stackId and dataKey

This aligns well with the PR's goal of adding more undefined checks.

test/cartesian/YAxis/YAxis.ticks.spec.tsx (1)

10-10: LGTM - Selector consistently renamed.

All usages of the axis settings selector have been properly updated to use selectRenderableAxisSettings, maintaining consistency with the broader refactoring.

Also applies to: 63-63, 117-117, 174-174, 229-229

src/state/selectors/polarSelectors.ts (2)

159-159: LGTM - Updated to use renderable axis settings.

The change to use selectRenderableAxisSettings instead of selectBaseAxis aligns with the project-wide refactoring and likely provides better type information for tick generation.


62-62: No action needed. The return type change from ChartData | undefined to ChartData is correct. The combineDisplayedData function already declares its return type as ChartData and all code paths return a ChartData value: either graphicalItemsData directly or the result of chartData.slice(), which always returns an array (never undefined).

src/state/selectors/combiners/combineAllBarPositions.ts (2)

26-26: LGTM!

Optional chaining on sizeList[0]?.barSize prevents potential runtime errors when the array is non-empty but the first element might be undefined or nullish.


55-57: Good fix for position tracking.

Assigning prev = newPosition.position correctly ensures the accumulator reflects the actual computed position for the next iteration, rather than using a stale reference.

src/state/selectors/combiners/combineBarSizeList.ts (4)

7-18: LGTM!

Type widening to string | number | undefined for globalSize properly supports percentage-based bar sizes.


30-38: Cleaner null-safe grouping logic.

The refactored approach with explicit null check and temporary variable is more defensive and handles missing stack arrays correctly.


40-44: LGTM!

Optional chaining on bars[0]?.barSize safely handles edge cases where a stack group might have an empty or sparse array.


64-64: Pre-existing any type in DataKey<any>.

The DataKey<any> type appears to be a pre-existing pattern in the codebase. While coding guidelines discourage any, this is likely inherited from the type definition rather than introduced in this PR.

src/state/selectors/barSelectors.ts (5)

29-29: LGTM!

Importing combineBarPosition centralizes bar position logic and reduces code duplication.


109-110: LGTM!

Return type tightened to always return SizeList, which is appropriate since combineBarSizeList always returns an array (possibly empty).


233-236: Good refactor to use centralized combiner.

Delegating to combineBarPosition improves maintainability and ensures consistent bar position logic across cartesian and polar charts.


268-295: LGTM!

Parameter types correctly widened to accept undefined for axes and barSettings, with comprehensive guard at lines 283-294 that short-circuits with undefined when any required value is missing.


112-139: Function correctly ensures number return type with no undefined fallback paths.

The function selectBarBandSize is newly added and has a return type of number, not number | undefined. The implementation guarantees a number is always returned through early returns of 0 (lines 119, 124) and the final nullish coalescing chain (?? maxBarSize ?? 0 at line 138).

src/state/selectors/radialBarSelectors.ts (8)

38-38: LGTM!

Consistent import of combineBarPosition for centralized bar position logic in polar charts.


59-64: LGTM!

Simplified signature and hardcoding isPanorama to false is correct since radial bar charts do not support panorama mode.


92-99: LGTM!

The comment at line 97 clearly documents the rationale for hardcoding isPanorama to false.


238-241: LGTM!

Return type tightened to always return SizeList, consistent with cartesian bar selector changes.


249-274: LGTM!

Return type changed to number with proper fallbacks to 0 via ?? maxBarSize ?? 0 at lines 270, 272. Parameter types widened to accept undefined for axis-related inputs.


301-304: Good refactor to use centralized combiner.

Consistent with the cartesian bar position selector, using combineBarPosition ensures unified bar position logic.


359-408: LGTM!

Parameter types properly widened to accept undefined, with comprehensive guard at lines 396-406 that returns an empty array when any required value is missing. Added checks for radiusAxisTicks and polarViewBox improve null safety.


438-446: LGTM!

legendType parameter now accepts undefined, with the type propagated correctly through the selector chain.

src/state/selectors/axisSelectors.ts (8)

253-274: LGTM!

Renaming from selectAxisSettings to selectRenderableAxisSettings improves clarity by indicating this selector returns settings for axes that can be rendered (excluding ZAxis).


560-564: LGTM!

Using selectRenderableAxisSettings for tooltip axis is consistent with the renamed selector.


1088-1090: LGTM!

Narrowing the return type to D3ScaleType improves type safety by ensuring only valid D3 scale names are returned.


1092-1141: LGTM!

Return type changed to D3ScaleType | undefined throughout the scale type selection chain, improving type precision.


1197-1197: LGTM!

Consistent use of selectRenderableAxisSettings for nice ticks computation.


1220-1224: Good defensive fallback for empty tick arrays.

Adding ?? 0 ensures that if niceTicks[0] or niceTicks[niceTicks.length - 1] is undefined (e.g., empty array edge case after length check), the computation still produces valid bounds.


1836-1845: LGTM!

Type updates to use D3ScaleType | undefined for realScaleType and ReadonlyArray<unknown> for categoricalDomain improve flexibility while maintaining type safety through runtime checks.

Also applies to: 1888-1891, 1964-1971, 1986-1989


1769-1771: LGTM!

Consistent use of selectRenderableAxisSettings across tick-related selectors maintains the refactored API surface.

Also applies to: 1943-1954, 2041-2051

@codecov
Copy link

codecov bot commented Dec 26, 2025

Codecov Report

❌ Patch coverage is 93.07692% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.54%. Comparing base (d52345f) to head (eafee34).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/chart/Treemap.tsx 42.85% 8 Missing ⚠️
src/state/selectors/barSelectors.ts 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6826      +/-   ##
==========================================
- Coverage   93.56%   93.54%   -0.02%     
==========================================
  Files         523      524       +1     
  Lines       46462    46476      +14     
  Branches     5055     5057       +2     
==========================================
+ Hits        43472    43477       +5     
- Misses       2983     2992       +9     
  Partials        7        7              

☔ 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
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
Copy link

codecov bot commented Dec 26, 2025

Bundle Report

Changes will increase total bundle size by 1.96kB (0.07%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.18MB 1.0kB (0.08%) ⬆️
recharts/bundle-es6 1.02MB 813 bytes (0.08%) ⬆️
recharts/bundle-umd 522.99kB 140 bytes (0.03%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 140 bytes 522.99kB 0.03%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
state/selectors/axisSelectors.js 246 bytes 54.08kB 0.46%
chart/Treemap.js 160 bytes 27.38kB 0.59%
cartesian/Scatter.js 34 bytes 22.61kB 0.15%
util/ChartUtils.js 38 bytes 18.41kB 0.21%
state/selectors/radialBarSelectors.js -195 bytes 11.18kB -1.71%
shape/Rectangle.js 91 bytes 10.77kB 0.85%
state/selectors/barSelectors.js -282 bytes 7.86kB -3.47%
state/cartesianAxisSlice.js 77 bytes 5.48kB 1.42%
state/selectors/combiners/combineAllBarPositions.js 75 bytes 4.4kB 1.73%
state/selectors/polarSelectors.js 44 bytes 3.65kB 1.22%
state/selectors/polarScaleSelectors.js 20 bytes 2.87kB 0.7%
state/selectors/combiners/combineBarSizeList.js 93 bytes 1.46kB 6.83% ⚠️
state/selectors/combiners/combineBarPosition.js (New) 386 bytes 386 bytes 100.0% 🚀
state/polarOptionsSlice.js 26 bytes 385 bytes 7.24% ⚠️
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
state/selectors/axisSelectors.js 276 bytes 64.09kB 0.43%
chart/Treemap.js 160 bytes 29.05kB 0.55%
cartesian/Scatter.js 34 bytes 24.24kB 0.14%
util/ChartUtils.js 38 bytes 20.5kB 0.19%
state/selectors/radialBarSelectors.js -175 bytes 12.72kB -1.36%
shape/Rectangle.js 91 bytes 12.05kB 0.76%
state/selectors/barSelectors.js -262 bytes 9.58kB -2.66%
state/cartesianAxisSlice.js 77 bytes 6.41kB 1.22%
state/selectors/combiners/combineAllBarPositions.js 75 bytes 4.66kB 1.64%
state/selectors/polarSelectors.js 14 bytes 4.55kB 0.31%
state/selectors/polarScaleSelectors.js 10 bytes 3.49kB 0.29%
state/selectors/combiners/combineBarSizeList.js 93 bytes 1.66kB 5.93% ⚠️
state/polarOptionsSlice.js 26 bytes 607 bytes 4.48%
state/selectors/combiners/combineBarPosition.js (New) 545 bytes 545 bytes 100.0% 🚀

@ckifer ckifer merged commit 5935b5c into main Dec 26, 2025
42 of 44 checks passed
@PavelVanecek PavelVanecek deleted the ts-strict branch December 26, 2025 16:21
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