Skip to content

6.5.0 Styled component union type regression #5787

Closed

Description

@lokalise-mark

Description

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

  1. Create a component whose props are a union type (button or anchor props here)
  2. Try to pass a prop which is described by one of the members of the union, but not the other ("href" in my example)
  3. Wrap the component in styled
  4. 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.

import styled from 'styled-components'

type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement>
type AnchorProps = React.AnchorHTMLAttributes<HTMLAnchorElement>
type PressableProps = ButtonProps | AnchorProps

const Link = (props: PressableProps) => null

const StyledLink = styled(Link)``

// 6.4.4: OK. 6.5.0: TS2769, "Property 'href' does not exist"
export const broken = <StyledLink href="/x">hi</StyledLink>

// Unstyled Link accepts href in both versions
export const fine = <Link href="/x">hi</Link>

Activity

  1. self-assigned this
    on Aug 6, 2026
  2. quantizor commented on Aug 6, 2026

    @quantizor
    Contributor

    Thank you will look into it

  3. added a commit that references this issue on Aug 6, 2026
    a0a92cd
  4. quantizor commented on Aug 6, 2026

    @quantizor
    Contributor

    Thank you for reporting, could you try [email protected] and let me know if it fixes your issue?

  5. lokalise-mark commented on Aug 7, 2026

    @lokalise-mark
    Author

    @quantizor Looks like you got it: TS errors are not present on the pre-release build. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions