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

(POC) Explicitly replace imports for AdapterDateFnsV3 #13325

Conversation

alexey-kozlenkov
Copy link
Contributor

Fixes #13226

This is POC of possible solution, requires review. If chosen approach considered to be OK, I will apply it to Jalali part too.

Why:

  • sources for imports in both DateFnsAdapter and DateFnsAdapterV3 are written isdate-fns, which in modules refers to date-fns v2 package
  • for V3 in babel config there is a replaces which let the right code for V3 get into the build
  • however this isn't happening when building types => types for V3 build are picked up from date-fns-V2 sources => wrong typings

Solution

  • explicitly change imports to use date-fns-v3 package for V3 adapter.
  • Pros:
    • get the right typings
  • Cons:
    • might increase bundle size (I wasn't able to run size commands on my local)
    • Will need some imports clean-up when switching to v3 by default

@mui-bot
Copy link

mui-bot commented May 31, 2024

Deploy preview: https://deploy-preview-13325--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 4554316

@alexey-kozlenkov
Copy link
Contributor Author

Brings breaking change, thus closing
ref: #13226 (comment)

@alexey-kozlenkov alexey-kozlenkov deleted the fix/adapter-date-fns-v3-types branch May 31, 2024 14:06
@zannager zannager added the component: pickers This is the name of the generic UI component, not the React module! label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pickers] AdapterDateFnsV3: Wrong types generated
3 participants