Skip to content

Use explicit types instead of inference#6710

Merged
ckifer merged 1 commit intomainfrom
EmptyObject
Dec 1, 2025
Merged

Use explicit types instead of inference#6710
ckifer merged 1 commit intomainfrom
EmptyObject

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Dec 1, 2025

Description

Typescript was reporting error in types, even though we never imported those types directly. Turns out that TS compiler would inline some inferred types in the output d.ts file which caused the trouble.

So in this PR I am replacing the inferred types with explicit types that do not need any imports.

Once this is merged I will enable the skiplibchecks in CI so that we are protected from regression.

Related Issue

Fixes #6664

How Has This Been Tested?

recharts/recharts-integ#83

Types of changes

  • 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:

  • 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
    • Internal type and selector signatures were standardized and the root store shape was made explicit to improve type safety and maintainability without changing runtime behavior.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

Introduces explicit TypeScript function signatures for several axis-related selectors and adds an explicit exported RechartsRootState type used to annotate rootReducer, replacing the previous ReturnType<typeof rootReducer> derivation. No runtime behavior changes.

Changes

Cohort / File(s) Summary
Selector Type Signatures
src/state/selectors/axisSelectors.ts
Added explicit exported function type signatures for five selectors: selectDomainOfStackGroups, selectReferenceDotsByAxis, selectErrorBarsSettings, selectAxisPropsNeededForCartesianGridTicksGenerator, and selectZAxisWithScale. Signatures now include (state, axisType, axisId, isPanorama)-style parameters and concrete return types; internal createSelector wiring and memoization preserved.
Store Root State Type Definition
src/state/store.ts
Introduced an explicit exported RechartsRootState type describing the root store shape (keys mapped to ReturnType of their reducers), imported Reducer from @reduxjs/toolkit, and annotated rootReducer as Reducer<RechartsRootState>. Removed the previous RechartsRootState = ReturnType<typeof rootReducer> derivation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Localized, non-behavioral TypeScript typing changes across two files.
  • Review focus:
    • Verify each selector's new public signature matches usage sites and exported declaration files.
    • Confirm RechartsRootState accurately reflects reducer return types and aligns with other type references (selectors, connected components).

Possibly related PRs

Suggested reviewers

  • ckifer

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Use explicit types instead of inference' directly and specifically captures the main change: replacing inferred types with explicit types to fix TypeScript errors.
Description check ✅ Passed The PR description covers all key sections: problem statement (inlined types causing errors), solution (explicit types), related issue, testing approach, and checklist items.
Linked Issues check ✅ Passed The PR successfully addresses issue #6664 by replacing inferred types that were causing 6 TypeScript errors (redux.EmptyObject and redux.CombinedState references) with explicit type definitions in axisSelectors.ts and store.ts.
Out of Scope Changes check ✅ Passed All changes are scoped to replacing inferred types with explicit types in two files (axisSelectors.ts and store.ts) to resolve the linked issue; no unrelated modifications detected.
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
  • Commit unit tests in branch EmptyObject

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9126328 and 298698b.

📒 Files selected for processing (2)
  • src/state/selectors/axisSelectors.ts (5 hunks)
  • src/state/store.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/state/store.ts
  • src/state/selectors/axisSelectors.ts
⏰ 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)

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.

@codecov
Copy link

codecov bot commented Dec 1, 2025

Bundle Report

Bundle size has no change ✅

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.03%. Comparing base (bf29f3e) to head (298698b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6710   +/-   ##
=======================================
  Coverage   94.03%   94.03%           
=======================================
  Files         500      500           
  Lines       42657    42662    +5     
  Branches     4901     4901           
=======================================
+ Hits        40111    40116    +5     
  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.

@PavelVanecek PavelVanecek added the typescript PRs or Issues surrounding Types or TS refactoring label Dec 1, 2025
Copy link
Member

@ckifer ckifer left a comment

Choose a reason for hiding this comment

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

Nice. I started to get towards this as a solution but didn't have the integ test to confirm 🙏

@ckifer ckifer merged commit 837d76f into main Dec 1, 2025
38 of 40 checks passed
@ckifer ckifer deleted the EmptyObject branch December 1, 2025 15:50
This was referenced Dec 8, 2025
@coderabbitai coderabbitai bot mentioned this pull request Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typescript PRs or Issues surrounding Types or TS refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[3.4.1] type errors with current release when skipLibCheck: false

2 participants