You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
6.5.0 Styled component union type regression #5787
After upgrading to 6.5.0, I'm seeing styled components whose props are typed with a union are now producing type errors. It appears as though only props which are present on every member of the union can be passed to the styled component.
Downgrading to 6.4.4 seems to resolve the issue.
Environment
react: 19.2.8
styled-components: 6.5.0
typescript: 5.9.3
Reproduction
Create a component whose props are a union type (button or anchor props here)
Try to pass a prop which is described by one of the members of the union, but not the other ("href" in my example)
Wrap the component in styled
Note that the wrapped version of the component produces an error whereas the original component does not
styled() on a component whose props are a union collapses that union to only the keys common to every member, so member-specific props are rejected at the JSX call site.
importstyledfrom'styled-components'typeButtonProps=React.ButtonHTMLAttributes<HTMLButtonElement>typeAnchorProps=React.AnchorHTMLAttributes<HTMLAnchorElement>typePressableProps=ButtonProps|AnchorPropsconstLink=(props: PressableProps)=>nullconstStyledLink=styled(Link)``// 6.4.4: OK. 6.5.0: TS2769, "Property 'href' does not exist"exportconstbroken=<StyledLinkhref="/x">hi</StyledLink>// Unstyled Link accepts href in both versionsexportconstfine=<Linkhref="/x">hi</Link>
Activity
quantizor commentedon Aug 6, 2026
Thank you will look into it
fix(types): keep union props through styled(), and stabilize the hook…
quantizor commentedon Aug 6, 2026
Thank you for reporting, could you try
[email protected]and let me know if it fixes your issue?lokalise-mark commentedon Aug 7, 2026
@quantizor Looks like you got it: TS errors are not present on the pre-release build. Thank you!
quantizor commentedon Aug 7, 2026
Sweet, just cut the 6.5.1 release! https://github.com/styled-components/styled-components/releases/tag/styled-components%406.5.1
Thanks again for reporting