fix: TypeScript type improvements for DatePicker props#6156
Merged
martijnrusschen merged 2 commits intomainfrom Dec 17, 2025
Merged
fix: TypeScript type improvements for DatePicker props#6156martijnrusschen merged 2 commits intomainfrom
martijnrusschen merged 2 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6156 +/- ##
=======================================
Coverage 99.25% 99.26%
=======================================
Files 30 30
Lines 3783 3792 +9
Branches 1627 1631 +4
=======================================
+ Hits 3755 3764 +9
Misses 27 27
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The minDate and maxDate props were not properly exposed in the DatePickerProps type due to a union type issue in CalendarProps. When showMonthYearDropdown was used, it picked from MonthYearDropdownProps which had required minDate/maxDate, causing TypeScript to not properly expose these props in the common case. Changes: - Updated CalendarProps to use YearDropdownProps (optional) instead of MonthYearDropdownProps (required) for minDate/maxDate - Made minDate/maxDate optional in MonthYearDropdownOptionsProps - Added default date range (±5 years) when minDate/maxDate not provided for MonthYearDropdown components Fixes #6143 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changed selectsRange and selectsMultiple from required literal `true` to optional `true` in the union type branches. This allows spreading props where these values might be `boolean | undefined` (e.g., from wrapper components using `Omit<DatePickerProps, 'onChange'>`). Added internal type aliases (OnChangeSingle, OnChangeRange, OnChangeMultiple) and type assertions in the component methods to maintain type safety while allowing the more flexible public API. Updated test files to use explicit type annotations for onChange callbacks since TypeScript can no longer infer the parameter type from the union. Fixes #6131 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
e47f6bc to
3a82fd1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two TypeScript type issues:
minDateandmaxDateprops not available in TypeScript typesselectsMultipletype error when spreading propsChanges
Fix for minDate/maxDate (#6143)
CalendarPropsto useYearDropdownProps(optional) instead ofMonthYearDropdownProps(required) forminDate/maxDateminDate/maxDateoptional inMonthYearDropdownOptionsPropsminDate/maxDatenot provided forMonthYearDropdowncomponentsFix for selectsRange/selectsMultiple spreading (#6131)
selectsRangeandselectsMultiplefrom required literaltrueto optionaltruein the union type branchesboolean | undefined(e.g., from wrapper components usingOmit<DatePickerProps, 'onChange'>)OnChangeSingle,OnChangeRange,OnChangeMultiple) and type assertions to maintain type safetyonChangecallbacksRoot Causes
#6143
In
CalendarProps, the union type forshowMonthYearDropdownwas usingPick<MonthYearDropdownProps, "maxDate" | "minDate">which inherited requiredminDate/maxDate. This caused TypeScript to not properly expose these props.#6131
The
selectsRange: trueandselectsMultiple: truewere typed as required literal types. When users spreadDatePickerProps(e.g.,Omit<DatePickerProps, 'onChange'>), these becomeboolean | undefined, which couldn't be assigned to the literaltrue.Fixes #6143
Fixes #6131
Test plan
🤖 Generated with Claude Code