Thanks to visit codestin.com
Credit goes to github.com

Skip to content

expose as and forwardedAs props in React.ComponentProps #5654

Open
XaveScor wants to merge 2 commits intostyled-components:mainfrom
XaveScor:main
Open

expose as and forwardedAs props in React.ComponentProps #5654
XaveScor wants to merge 2 commits intostyled-components:mainfrom
XaveScor:main

Conversation

…led-components#4294)

TypeScript's React.ComponentProps utility type couldn't extract the `as` and `forwardedAs` props from styled components, even though these props worked correctly in JSX.

The issue was that PolymorphicComponent extended ForwardRefExoticComponent with only BaseProps, so the polymorphic props were only visible in the call signature but not in the component's static type that React.ComponentProps extracts.

Fixed by including `as` and `forwardedAs` in the base props type passed to ForwardRefExoticComponent, making them visible to React.ComponentProps while maintaining full backward compatibility.
@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2026

🦋 Changeset detected

Latest commit: 2c00ba7

The changes in this PR will be included in the next version bump.

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

XaveScor

This comment was marked as off-topic.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot infer the 'as' and 'forwardedAs' props by React.ComponentProps

1 participant