Skip to content

Conversation

@martijnrusschen
Copy link
Member

This fix addresses issue #5391 where TypeScript was not properly inferring the onChange callback type based on selectsRange and selectsMultiple props.

The problem was that using 'never' as the discriminant type for optional properties didn't allow TypeScript to properly narrow the union type.

Changes:

  • Changed selectsRange?: never to selectsRange?: false | undefined
  • Changed selectsMultiple?: never to selectsMultiple?: false | undefined
  • Updated test file to use correct type for selectsMultiple prop

This allows TypeScript to correctly infer:

  • onChange receives Date | null when selectsRange is false/undefined
  • onChange receives [Date | null, Date | null] when selectsRange is true
  • onChange receives Date[] | null when selectsMultiple is true

Fixes #5391

This fix addresses issue #5391 where TypeScript was not properly inferring
the onChange callback type based on selectsRange and selectsMultiple props.

The problem was that using 'never' as the discriminant type for optional
properties didn't allow TypeScript to properly narrow the union type.

Changes:
- Changed selectsRange?: never to selectsRange?: false | undefined
- Changed selectsMultiple?: never to selectsMultiple?: false | undefined
- Updated test file to use correct type for selectsMultiple prop

This allows TypeScript to correctly infer:
- onChange receives Date | null when selectsRange is false/undefined
- onChange receives [Date | null, Date | null] when selectsRange is true
- onChange receives Date[] | null when selectsMultiple is true

Fixes #5391
@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6078      +/-   ##
==========================================
+ Coverage   99.14%   99.22%   +0.08%     
==========================================
  Files          30       30              
  Lines        3612     3612              
  Branches     1551     1547       -4     
==========================================
+ Hits         3581     3584       +3     
+ Misses         29       27       -2     
+ Partials        2        1       -1     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martijnrusschen martijnrusschen merged commit a9517e4 into main Dec 1, 2025
6 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.

Date Picker Type issue

2 participants