Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers] Remove TDate generics in favor of PickerValidDate direct usage #15001

Merged
merged 70 commits into from
Nov 5, 2024

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Oct 16, 2024

Closes #14796

Side note: all PickerValidDate | null passed as a generic will be replaced with a true or false once TValue is replaced by TIsRange (phrase 2 of #14823).

I will do the migration guide after the phase 2 of #14823 to have a finalized list of the breaking changes on the generics.

Changelog

Pickers

  • The TDate generic has been removed from all the types, interfaces, and variables of the @mui/x-date-pickers and @mui/x-date-pickers-pro packages.

    If you were passing your date object type as a generic to any element of one of those packages, you can remove it:

    -<DatePicker<Dayjs> value={value} onChange={onChange} />
    +<DatePicker value={value} onChange={onChange} />
    
    -type Slot = DateCalendarSlots<Dayjs>['calendarHeader'];
    +type Slot = DateCalendarSlots['calendarHeader'];
    
    -type Props = DatePickerToolbarProps<Dayjs>;
    +type Props = DatePickerToolbarProps;

    A follow-up release will add the full list of the impacted elements to the migration guide.

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 29, 2024
Co-authored-by: Lukas Tyla <[email protected]>
Signed-off-by: Flavien DELANGLE <[email protected]>
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 29, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 29, 2024
@flaviendelangle
Copy link
Member Author

@LukasTy one option would be to add the following code in one of the doc files:

declare module '@mui/x-date-pickers/models' {
  interface PickerValidDateLookup {
    fakeDocAdapter: any;
  }
}

It would not impact Codesandbox / Stackblitz.
We would have any as a value in the doc examples but I don't think we care since today we have the union of all the date library types and we never really missed this type safety.

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 31, 2024
@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Oct 31, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 31, 2024
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

Epic work! 💯 🚀 🌔
Massive piece of destruction and cleanup. 👏

Leaving some non-blocking comments. 😉

@flaviendelangle flaviendelangle merged commit c41bfaa into mui:master Nov 5, 2024
16 checks passed
@flaviendelangle flaviendelangle deleted the remove-tdate branch November 5, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: pickers This is the name of the generic UI component, not the React module! typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pickers] Replace the TDate generic with PickerValidDate in every type / interface
3 participants