-
-
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] AdapterDateFnsV3: Wrong types generated #13226
Comments
Thanks @alexey-kozlenkov for opening this issue. 👍🏼 |
@michelengelen I made a POC with a possible option to solve this, if team could have a look and decide if that's viable would be great |
@alexey-kozlenkov Thank you for your contribution! 🙏 We'll have to look for an alternative solution. 👍 |
Ah, I see, thanks @LukasTy. |
We've decided to try an approach of adding explicit function returns in hopes of fixing this problem in the built packages. An example of the idea: - public isSameYear = (value: Date, comparing: Date) => {
+ public isSameYear = (value: Date, comparing: Date): boolean => { @alexey-kozlenkov would you be interested in taking care of this problem with the suggested approach? 🤔 |
@LukasTy yeah, sure |
Would this be why I'm unable to assign anything to a date picker? I'm getting this error when the type is Or would I be experiencing a different issue? Relevant dependencies:
Typescript error:
Weirdly not running into this issue on a code sandbox though: |
@eglavin do you have a |
Ahh ok yeah importing it directly in the project its self seems to make it work correctly. kinda breaks what we're doing though. Essentially we have a micro-frontend stack which means our theme config is in a separate library which contains our theme providers like so:
This ThemeProvider component is then bundled in an internal npm package which gets installed onto each micro-frontend, how does typescript then know which adapter is being used? is there a mechanism to tell typescript which adapter is being used without importing it into every frontend app? |
Ok I see it, you have this interface declared in the adapter function. I'll be able to use this to get it to register, thanks for you're help @LukasTy!
|
Are all your frontend apps using |
Most if not all do yes, this will work for now, thanks again! 😁 |
@alexey-kozlenkov: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Steps to reproduce
Link to live example: (https://codesandbox.io/p/sandbox/brave-matsumoto-9t8tqx?file=%2Fsrc%2FDemo.tsx%3A16%2C2)
Steps:
const res
intest
functionCurrent behavior
Return types of
AdapterDateFnsV3
functions are mostlyany
instead of their actual valuesExpected behavior
Correspond to
MuiPickersAdapter
interfaceContext
I'm trying to write an extended version of
DateUtilsAdapterV3
with some custom utility functions and they reuse function ifDateUtilsAdapterV3
, which provides wrong typings.Your environment
Executed in a devbox: https://codesandbox.io/p/devbox/y8p8k9?file=%2Fsrc%2FDemo.tsx%3A5%2C48
``` Don't forget to mention which browser you used. System: OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm) Binaries: Node: 20.9.0 - /usr/local/bin/node npm: 9.8.1 - /usr/local/bin/npm pnpm: 8.10.2 - /usr/local/share/npm-global/bin/pnpm Browsers: Chrome: Not Found npmPackages: @emotion/react: latest => 11.11.4 @emotion/styled: latest => 11.11.5 @mui/material: next => 6.0.0-alpha.8 @mui/x-date-pickers: latest => 7.5.1 @types/react: latest => 18.3.2 react: latest => 18.3.1 react-dom: latest => 18.3.1 typescript: latest => 5.4.5 ```npx @mui/envinfo
Used browser: Version 125.0.6422.61 (Official Build) (arm64)
Search keywords: adapterdatefnsv3 date-fns date-fns-v3
The text was updated successfully, but these errors were encountered: