-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Replace TValue
and TSection
generics with TIsRange
#15290
Conversation
Deploy preview: https://deploy-preview-15290--material-ui-x.netlify.app/ |
8bb1bd4
to
5d145b6
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@@ -45,7 +46,7 @@ describe('<MobileDateRangePicker /> - Describes', () => { | |||
], | |||
})); | |||
|
|||
describeValue(MobileDateRangePicker, () => ({ | |||
describeValue<true, 'picker'>(MobileDateRangePicker, () => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before the value was any
(since TValue
doesn't have any extend
attached to it).
But now that we have a good typing, it complains that value
has the type PickerValue | PickerRangeValue
which is not compatible with a lot of the things we do in setNewValue
.
So I added manual generics to fix that.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel slightly unsure about these changes. 🤔
Passing only a boolean into a generic type feels slightly "over-optimized". 🙈
Sometimes a bit of explicitness is warranted.
Are you sure about this direction?
packages/x-date-pickers-pro/src/internals/hooks/useMultiInputFieldSelectedSections.ts
Outdated
Show resolved
Hide resolved
: PickerRangeValue | ||
: PickerValue; | ||
|
||
export type InferNonNullablePickerValue<TIsRange extends boolean> = TIsRange extends true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that we need to put this logic and the RangePosition
in the community package raises some "concern flags" in my head about the direction of the solution. 🙈
We can discuss it in the coming days. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
6e015da
to
9e7e9aa
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Replaced with #15434
Part of #14823 (step 2)
I will handle the migration guide in a follow up 👍
Example