Skip to content

Export PieSectorShapeProps type#6706

Merged
ckifer merged 1 commit intorecharts:mainfrom
ramanverse:feature/export-pie-sector-shape-props
Nov 30, 2025
Merged

Export PieSectorShapeProps type#6706
ckifer merged 1 commit intorecharts:mainfrom
ramanverse:feature/export-pie-sector-shape-props

Conversation

@ramanverse
Copy link
Contributor

@ramanverse ramanverse commented Nov 29, 2025

Export PieSectorShapeProps Type

Summary

This PR makes the PieSectorShapeProps type publicly available, improving the developer experience when working with custom Pie chart shapes.

Problem

Currently, when developers want to create custom shape functions for Pie components, they need to manually recreate the PieSectorShapeProps type by adding the isActive property to PieSectorDataItem. This is error-prone and requires developers to inspect the internal implementation to understand the shape of the props.

// Before: Developers had to manually type this
type MyPieShapeProps = PieSectorDataItem & { isActive: boolean; index: number };

const customShape = (props: MyPieShapeProps) => {
  // custom implementation
};

Solution

This PR exports the PieSectorShapeProps type, allowing developers to use it directly:

// After: Developers can import and use the official type
import { PieSectorShapeProps } from 'recharts';

const customShape = (props: PieSectorShapeProps) => {
  // custom implementation
};

Changes

  1. src/polar/Pie.tsx - Added export keyword to the PieSectorShapeProps type definition (line 163)
  2. src/index.ts - Added PieSectorShapeProps to the list of exported types from ./polar/Pie (line 56)

Testing

  • ✅ Type definitions build successfully (npm run build-types)
  • ✅ No breaking changes to existing code
  • ✅ The type is now available for import by consumers

Benefits

  • Improved developer experience
  • Better type safety
  • Reduced code duplication
  • Clearer API surface

Fixes

#6705

Summary by CodeRabbit

  • API Updates
    • Made PieSectorShapeProps type publicly available for use in Pie component implementations.
    • Exposed RadialBarProps type for RadialBar component integration.
    • Enhanced TypeScript support for developers using Polar chart components.

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

This change makes the PieSectorShapeProps type publicly available by:
1. Adding 'export' keyword to the type definition in src/polar/Pie.tsx
2. Re-exporting it from src/index.ts

This allows consumers to directly use this type when creating custom
shape functions for Pie components, instead of manually recreating it
by adding the isActive property to PieSectorDataItem.

Fixes recharts#6705
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 29, 2025

Walkthrough

The PR expands the public API by exporting two type definitions: PieSectorShapeProps from the Pie component and RadialBarProps from the RadialBar component. These changes expose previously internal types to library consumers, with no runtime logic modifications.

Changes

Cohort / File(s) Change Summary
Type Export Extensions
src/index.ts, src/polar/Pie.tsx
Added export modifier to PieSectorShapeProps type declaration in Pie.tsx. Updated export type block in index.ts to include PieSectorShapeProps alongside existing Pie exports, and added new RadialBarProps export from RadialBar module.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Straightforward type export additions with no logic changes
  • Consistent pattern applied across two files
  • Clear alignment with existing export structure

Possibly related issues

Possibly related PRs

Suggested reviewers

  • ckifer
  • PavelVanecek

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Export PieSectorShapeProps type' is concise, specific, and accurately describes the main change—exporting a new type for public use.
Description check ✅ Passed The description covers the problem, solution, changes made, and testing performed. However, the template's 'Types of changes' and 'Checklist' sections are not filled out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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

🧹 Nitpick comments (1)
src/polar/Pie.tsx (1)

163-163: LGTM! Type export is correctly implemented.

The addition of the export keyword successfully makes PieSectorShapeProps publicly available, which achieves the PR's goal of improving developer experience when creating custom Pie shapes.

Optional improvement: Consider adding JSDoc documentation similar to PieSectorDataItem above (lines 147-156) to help developers understand when and how to use this type:

+/**
+ * Props passed to custom shape functions when rendering Pie sectors.
+ * Extends PieSectorDataItem with additional rendering state.
+ */
 export type PieSectorShapeProps = PieSectorDataItem & { isActive: boolean; index: number };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3ccaac and 451f271.

📒 Files selected for processing (2)
  • src/index.ts (1 hunks)
  • src/polar/Pie.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (DEVELOPING.md)

Run ESLint and Prettier on the codebase using npm run lint

Files:

  • src/polar/Pie.tsx
  • src/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (DEVELOPING.md)

Run type checking on the codebase using npm run check-types

**/*.{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/polar/Pie.tsx
  • src/index.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/polar/Pie.tsx
  • src/index.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/polar/Pie.tsx
  • src/index.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.388Z
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.
📚 Learning: 2025-11-23T13:30:10.388Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.388Z
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/polar/Pie.tsx
  • src/index.ts
🧬 Code graph analysis (1)
src/polar/Pie.tsx (1)
src/index.ts (2)
  • PieSectorShapeProps (61-61)
  • PieSectorDataItem (60-60)
🔇 Additional comments (1)
src/polar/Pie.tsx (1)

56-62: I encountered a repository access issue and cannot clone the codebase to verify the review comment. However, I can note that the provided review comment appears to have mismatched content — the snippet shows imports in src/polar/Pie.tsx, but the review discussion and scratchpad reference exports from src/index.ts and a different file structure.

To proceed with verification, I need either:

  1. Direct access to the codebase files, or
  2. Clarification on what changes are actually being reviewed at lines 56-62 of src/polar/Pie.tsx

Could you provide the context again or confirm the actual file path and changes under review?

@codecov
Copy link

codecov bot commented Nov 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.02%. Comparing base (d3ccaac) to head (451f271).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6706   +/-   ##
=======================================
  Coverage   94.02%   94.02%           
=======================================
  Files         499      499           
  Lines       42625    42625           
  Branches     4892     4892           
=======================================
  Hits        40079    40079           
  Misses       2541     2541           
  Partials        5        5           

☔ 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.

@ramanverse
Copy link
Contributor Author

@ckifer Please review the changes and suggest improvements if any!

@ckifer ckifer merged commit efd8824 into recharts:main Nov 30, 2025
22 checks passed
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