-
Notifications
You must be signed in to change notification settings - Fork 529
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
Update types for IconButton, ActionMenu.Button, TabNav.Link and internal consumers #2677
Conversation
🦋 Changeset detectedLatest commit: 4761a20 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 📦
|
children: React.ReactNode | ||
} & ButtonBaseProps | ||
|
||
export type IconButtonProps = ButtonA11yProps & { | ||
icon: React.FunctionComponent<React.PropsWithChildren<IconProps>> | ||
icon: React.ComponentType |
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.
broadens these to they work with arbitrary components, and not only primer octicons
@@ -105,9 +106,8 @@ const TabNavLink = styled.a.attrs<StyledTabNavLinkProps>(props => ({ | |||
} | |||
|
|||
${sx}; | |||
` | |||
` as PolymorphicForwardRefComponent<'a', TabNavLinkProps> |
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 is used polymorphically, but the styled-components as types conflict some with the polymorphic helper types - overriding the styled-components version gives better typing, and avoids those issues
} | ||
|
||
export function shouldAcceptTabNavLinkprops() { | ||
return <TabNav.Link to="to something" selected as={Button} /> |
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.
validates that we can accept specific props, and as
@joshblack opened this one - https://github.com/github/github/pull/252052 Which fixes up the type errors in dotcom. We'd probably need to work with product teams to ensure the aria-labels added are good enough, but it does the heavy lifting. This did uncover some additional fixes necessary to improve the and opens a new question related to a test. This updates the types to support a test we have currently in this codebase. I think the test, incorrectly, accepts an |
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.
Looks great. Thanks for taking this on @mattcosta7 and @joshblack! 💖
Describe your changes here.
The types for these buttons have seemed incorrect for some time. This should correct these types and ensure they get proper autocompletion in IDEs. I'm not 100% sure if the polymorphism on AnchorMenu.Button is correct, but it's consistent with what the types purported to be previously as far as I can tell
fixes #2622
fixes #2519
Are there are, similar instances we should fixup while here?
I snuck in a small change more broadly, which replaces
This should avoid a new object allocation on every render of multiple components, and potentially memo/callback/effect re-evaluations related to them. I don't expect a significant perf improvement, but this should be a small one with no negative effects
These changes lead to many incompatible typings inside primer, which I've fixed up. I think there are likely many more typing inconsistencies in primer we should work to root out, but this should at least build as expected.
A consideration here is "Are these fixes broad enough to be considered breaking changes" as they'll likely require consumers to update code, similar to what we've had to do here
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.