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
chore(project): update TypeScript to v4.8.3 #2360
Conversation
🦋 Changeset detectedLatest commit: 6f8b95d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
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.
This seems reasonable 👍 Thanks for updating this, @joshblack!
Could these changes lead to runtime errors if these components are passed children that they don't expect? For example, would React.cloneElement(child as React.ReactElement<AvatarProps>, {size: 40})
cause problems if child
is not React.ReactElement<AvatarProps>
?
This PR updates TypeScript to v4.8.3. Generally, the changes made were around calls to
React.cloneElement
when thechild
arg wasunknown
. This lead to errors in the shape:This comes up in
React.Children.{map,toArray}
calls if thechildren
type is the more general typeReact.ReactNode
instead of a specific type thatcloneElement
is expecting.For example, consider a
List
component that expectsListItem
children:This example would encounter the above error since the author is expecting the child to be of type
ListItemProps
.To address this, I believe we need to narrow the type through type assertions and this is the approach the PR takes