expose as and forwardedAs props in React.ComponentProps #5654
Open
XaveScor wants to merge 2 commits intostyled-components:mainfrom
Open
expose as and forwardedAs props in React.ComponentProps #5654XaveScor wants to merge 2 commits intostyled-components:mainfrom
as and forwardedAs props in React.ComponentProps #5654XaveScor wants to merge 2 commits intostyled-components:mainfrom
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 detectedLatest 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #4294
I've uploaded the fix as
@xavescor/signal-component.You can validate it here:
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAKjgQwM5wEoFNkGN4BmUEIcARFDvmQNwBQokscqMAngDZYAmcRJ5Vpx4BaXCUgA7LJJipaDcNHhCu3AArIYACx59ipMgAEAHsgBuWVOKgB6VaPFLpshXXGTWcAIJwAvCzsagB03MDmAAYR9HS2tnAAytoQAO7oyHDsYFa4UMBg8FhQxFBwwJJw5gCswQAswVV0WVhwACoAjP6YVDDBAMISEC4w6sRgqAA8zRAEPgB8ANpkaGQAuk1s2W0ATF3YeL0DzjIjY5PTs96LZATQKchQ3Dze8uux8QBGAK7wkhBwRRKcF0lDoE18aD8AHJkFC4LY5vRwXw7g8ntwXtDYfDEXR3v4-ISiQF1N5WgAJACiABE8R4vN5NDo9AEHBotLpuKFwlEYnFEsk0ihMpscnkCgDitAyhVqnUGhsth0mZy9j1+oNhqMIOMpqKZj4VTxrit1s0dkbeAF9vgNcdZNrdRdDRzjUtblB7o9nq88fzvr9-oDpSCsGDGa7eJCYXCEUiI8zeB6vejMTGcTQgA
I've tried to cover it by the types test but I'm not sure I did it correctly.