Skip to content

Conversation

@martijnrusschen
Copy link
Member

@martijnrusschen martijnrusschen commented Dec 17, 2025

Summary

This PR fixes two TypeScript type issues:

  1. Property 'minDate' does not exist on type 'IntrinsicAttributes & ((Partial<Pick<Omit<CalendarProps,.... #6143 - minDate and maxDate props not available in TypeScript types
  2. selectsMultiple - Type 'boolean | undefined' is not assignable to type 'true'. #6131 - selectsMultiple type error when spreading props

Changes

Fix for minDate/maxDate (#6143)

  • 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

Fix for selectsRange/selectsMultiple spreading (#6131)

  • 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 to maintain type safety
  • Updated test files to use explicit type annotations for onChange callbacks

Root Causes

#6143

In CalendarProps, the union type for showMonthYearDropdown was using Pick<MonthYearDropdownProps, "maxDate" | "minDate"> which inherited required minDate/maxDate. This caused TypeScript to not properly expose these props.

#6131

The selectsRange: true and selectsMultiple: true were typed as required literal types. When users spread DatePickerProps (e.g., Omit<DatePickerProps, 'onChange'>), these become boolean | undefined, which couldn't be assigned to the literal true.

Fixes #6143
Fixes #6131

Test plan

  • All 1445 existing tests pass
  • TypeScript type-check passes
  • Linter passes

🤖 Generated with Claude Code

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.26%. Comparing base (8b66e0d) to head (3a82fd1).
⚠️ Report is 5 commits behind head on main.

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.
📢 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 and others added 2 commits December 17, 2025 18:43
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>
@martijnrusschen martijnrusschen force-pushed the fix/mindate-maxdate-typescript-types branch from e47f6bc to 3a82fd1 Compare December 17, 2025 17:51
@martijnrusschen martijnrusschen changed the title fix: make minDate and maxDate props available in TypeScript types fix: TypeScript type improvements for DatePicker props Dec 17, 2025
@martijnrusschen martijnrusschen merged commit ec2034d into main Dec 17, 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

2 participants