-
Notifications
You must be signed in to change notification settings - Fork 514
chore: update types for react #6191
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
base: master
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@bryceosterhaus @ethib137 This LGTM. Let me know if I shouldn't merge it. |
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.
Hey @bryceosterhaus there are a lot of changes that appear to be more than just changing types. Maybe we should have a call to go over briefly what these changes are and why they are necessary?
| > { | ||
| 'aria-label'?: string; | ||
|
|
||
| 'aria-labelledby'?: string; |
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 old type looked like it was requiring either aria-labelledby or aria-label to be included while also not allowing both to be added at the same time. This doesn't look like this will have the same behavior.
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.
For some reason with the updated type libraries, it no longer allowed them to be mutually exclusive. I'm not exactly why or what type changed in the react definitions, but I figured it might just be simpler to make them both optional types instead.
| const hasItems = (children?: React.ReactNode) => { | ||
| if (!children) { | ||
| const hasItems = (children?: React.ReactNode | Function) => { | ||
| if (!children || typeof children === 'function') { |
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.
What required this change?
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.
Because React.Children.map no longer accepts the function type, so we have to guard against that.
Additionally we have to add Function as a suspected type to hasItems because in ClayAutocomplete the children prop can be a function
Essentially there were gaps in the previous types, so I think it just got more strict.
This is needed for the dxp migration since dxp uses v18 react types. Lets see what CI says...
Also, we don't necessarily need to merge this here. I can just copy/paste these changes to the dxp migration PR