[TypeScript] add BarShapeProps type to fix Bar.shape type#6900
Conversation
WalkthroughIntroduces a new public type Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/cartesian/Bar.tsx`:
- Around line 115-116: BarShapeProps currently uses `option?: any`; replace this
with the specific option type used by BarRectangleProps to avoid `any` — e.g.
change `option?: any` to `option?: BarRectangleProps['option']` (referencing the
existing BarRectangleProps type used in BarUtils) so the prop uses the
established precise type instead of `any`.
In `@src/util/BarUtils.tsx`:
- Around line 5-10: Change the option field on the BarShapeProps type in
src/cartesian/Bar.tsx from option?: any to option?: unknown and then update any
consumer code to explicitly narrow or validate that option before using it
(e.g., add type guards or runtime checks where BarShapeProps or
ActiveShape<BarShapeProps, ...> is consumed). Specifically modify the
BarShapeProps type declaration (the option property), and then search for usages
such as in ActiveShape<BarShapeProps, SVGPathElement>, BarRectangleProps, and
any functions that access option to add proper type refinement or safe casts so
no code assumes properties on option without checking. Ensure exports and
imports remain consistent so BarUtils and other modules compile with the new
unknown type.
🧹 Nitpick comments (1)
www/src/docs/exampleComponents/BarChart/CandlestickExample.tsx (1)
5-5: Prefer a typed intersection to remove@ts-expect-error.Since the shape props include the data payload, model it explicitly as
BarShapeProps & MarketCandleand drop the ts-expect-error.♻️ Suggested change
-const Candlestick = (props: BarShapeProps) => { - // `@ts-expect-error` Recharts does spread MarketCandle on the props but the types don't reflect that - const color = props.open < props.close ? 'green' : 'red'; +const Candlestick = (props: BarShapeProps & MarketCandle) => { + const color = props.open < props.close ? 'green' : 'red';Also applies to: 37-40
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6900 +/- ##
=======================================
Coverage 94.27% 94.27%
=======================================
Files 565 565
Lines 53858 53859 +1
Branches 5178 5178
=======================================
+ Hits 50777 50778 +1
Misses 3072 3072
Partials 9 9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Staging Deployment Details
These deployments will remain available for 30 days. To update snapshots: Comment |
Bundle ReportBundle size has no change ✅ |
Description
New type to accurately describe what Bar.shape is doing.
Related Issue
Motivation and Context
Nobody has complained yet but I found it embarrassing that our own examples have to use @ts-expect-error to compile.
Types of changes
Checklist:
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.