Fix Legend props not appearing in omnidoc website#7203
Conversation
…icComponent type Agent-Logs-Url: https://github.com/recharts/recharts/sessions/e432a617-4329-401c-ba11-0c6b48150687 Co-authored-by: PavelVanecek <[email protected]>
Bundle ReportChanges will increase total bundle size by 50 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-cjsAssets Changed:
view changes for bundle: recharts/bundle-umdAssets Changed:
view changes for bundle: recharts/bundle-es6Assets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7203 +/- ##
=======================================
Coverage 89.06% 89.06%
=======================================
Files 539 539
Lines 41011 41012 +1
Branches 5553 5554 +1
=======================================
+ Hits 36527 36528 +1
Misses 4476 4476
Partials 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…icComponent type Agent-Logs-Url: https://github.com/recharts/recharts/sessions/e432a617-4329-401c-ba11-0c6b48150687 Co-authored-by: PavelVanecek <[email protected]>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThe PR extends TypeScript prop-type resolution for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
Staging Deployment Details
These deployments will remain available for 30 days. To update snapshots: Comment |
Legend component props were missing entirely from the generated API documentation on the website because
omnidoc/readProject.tsfailed to extract props fromReact.memo-wrapped components without an explicit type annotation.Root Cause
Legend = React.memo(LegendImpl, propsAreEqual)produces typeReact.MemoExoticComponent<typeof LegendImpl>. The alias symbol isMemoExoticComponentand its alias type argument is the wrapped function type (typeof LegendImpl), not the Props type directly. The code path fell through togetTypeArgumentsOfComponentType(), which returned the function type as-is — causingcollectPropertiesFromTypeto find zero properties.Contrast with components annotated as
: ComponentType<Props>(e.g.BarStack) where the alias type argument is the Props type, and those work fine.Changes
omnidoc/readProject.ts— IngetPropsType, detectMemoExoticComponentalias and extract the Props type from the inner function's call signature first parameter:src/component/Legend.tsx— AddedlabelStyle: {}tolegendDefaultPropsto match the@defaultValue {}JSDoc inherited fromDefaultLegendContentProps. This pre-existing inconsistency was hidden while Legend had 0 props discovered; now surfaces and is fixed.www/src/docs/api/LegendAPI.tsx— Regenerated; now contains the full Legend prop list with descriptions, defaults, and examples.test/component/Legend.spec.tsx,test/component/Legend.itemSorter.spec.tsx— Updated expectations for props passed to content functions to includelabelStyle: {}.Related Issue
Legend props don't appear on the website (omnidoc generation bug).
Motivation and Context
Without this fix, the Legend API documentation page on recharts.org shows no props at all, making it unusable as a reference.
How Has This Been Tested?
npx vitest run omnidoc/— 515 tests passnpx vitest run test/component/Legend.spec.tsx test/component/Legend.itemSorter.spec.tsx— 335 tests passnpx tsx omnidoc/generateApiDoc.ts—LegendAPI.tsxnow emits a full props arrayScreenshots (if appropriate):
Types of changes
Checklist:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
storybook.js.org/opt/hostedtoolcache/node/24.14.0/x64/bin/node node /home/REDACTED/work/recharts/recharts/node_modules/.bin/vitest run omnidoc/omnidoc.spec.ts(dns block)/opt/hostedtoolcache/node/24.14.0/x64/bin/node node /home/REDACTED/work/recharts/recharts/node_modules/.bin/vitest run omnidoc/(dns block)/opt/hostedtoolcache/node/24.14.0/x64/bin/node node /home/REDACTED/work/recharts/recharts/node_modules/.bin/vitest run omnidoc/ -c cat /proc/cpuinfo | grep "physical id" | sort |uniq | wc -l grep /usr/bin/wc o | grep "core igit node 0/x64/bin/node wc -l odules/npm/node_modules/@npmcli/run-script/lib/ncat /proc/cpuinfo | grep "core id" | sort | uniqbash 0/x64/bin/node /usr/bin/sort cat /proc/cpuinfcat sh /usr/bin/wc sort(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Summary by CodeRabbit
labelStyledefault property, providing enhanced customization options for label styling with sensible default values.