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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DatePicker] Needs to be generic over TDate #5388
Comments
Related to mui/material-ui-pickers#2045. |
So the two solutions are (a) dragging What's your current opinion/plan on this? |
In https://codesandbox.io/s/staticdaterangepicker-material-demo-forked-j9y1x?file=/demo.tsx, the type seems correct. Could you expand? |
You're right, it didn't work because I had overridden some props assuming Let me reformulate as a feature request: I want to be able to provide (from my "application library" to my "application code") a DatePicker component that uses So I imagine something like |
@Philipp91 Ok, so the issue isn't specific to the date range picker but also ranges to the date picker. This sounds like a good idea. Do you want to work on it? |
That's right, it's not specific to the range picker. Sadly I haven't found the time to work on it, and likely I won't. In my application, I can work around the issue with a couple of |
Fixed by #4617 We will write a doc page to fully document it in the future |
@flaviendelangle Hi, is it possible to share the link to documentation for this change of additional generics |
Hi, Sorry for the delay |
Current Behavior 馃槸
When I do:
then
StaticDateRangePickerProps
does not know theTDate
, i.e. it usesunknown
. This means that simple things like this don't work:TypeScript rightfully complains that the
value
prop coming into my component is of typeRangeInput<unknown>
and thus not assignable to theStaticDateRangePicker.value
prop, which is of typeRangeInput<Date>
. Similar issues exist withminDate
,maxDate
andonChange
.Expected Behavior 馃
StaticDateRangePickerProps
should be generic<TDate = unknown>
or even<TDate = Date>
, allowing me to use the props type as usual and customize it when necessary.Steps to Reproduce 馃暪
I tried putting together a live example, but I don't know how to import the latest alpha of the lab there.
Context 馃敠
I'm trying to wrap the built-in component in a custom one which converts dates to local time in some way, adds some default property values, etc.
Your Environment 馃寧
`npx @material-ui/envinfo`
tsconfig
The text was updated successfully, but these errors were encountered: