-
-
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] The value
prop is not correctly typed
#14765
Comments
Hi, You should be able to fix your problem using this doc section |
@LukasTy if this is doable, would you be in favor of typing the date to EDIT: It seems to work |
value
prop is not correctly typed
This solved it! Thank you. I suggest making this doc more prominent. Maybe making typescript a top level document. |
Oh, shoot. 🙈 |
The main downside is that people won't discover how to actually get the correct typing. People with a classic setup will have a correct typing like today Not sure how to get the best of both worlds though... |
Yes, that is not an ideal downside, but I think that fallback is still better than a case where you can hardly avoid the error.
I don't think we can, given how the typing is setup and the various use cases that users might have. 🤷 |
I also think Maybe we could just add one line in the JSDoc of the |
Yes, I came to the same solution. Steer users to the documentation on how to fix it. 🤔 🙈 |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note We value your feedback @aqeelat! How was your experience with our support team? |
Steps to reproduce
Link to live example: https://stackblitz.com/edit/github-gm5jav
It is very hard to create a shareable repro, but the component could be a simple
<DatePicker value={new Date()} />
Current behavior
value
only acceptsnull
orundefined
Expected behavior
To have the correct type
Context
It is very hard to create a shareable repro, but the issue is that we have a monorepo with a couple of react apps, and a separate package for our common stuff such as ui elements and forms, some of which have DatePickers.
However, because we're not surrounding our shared components with a LocalizationProvider, the type for
DatePicker.value
becomesnever
. (but the packages that use them do actually have LocalizationProviders that are setup correctly)Your environment
npx @mui/envinfo
Search keywords: datepicker type value
The text was updated successfully, but these errors were encountered: