Skip to content
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

Building Strongly Typed Polymorphic Components #18275

Open
13 tasks
guidari opened this issue Dec 26, 2024 · 0 comments
Open
13 tasks

Building Strongly Typed Polymorphic Components #18275

guidari opened this issue Dec 26, 2024 · 0 comments

Comments

@guidari
Copy link
Contributor

guidari commented Dec 26, 2024

When using PolymorphicProps in Carbon, we are not accounting for type errors. For example, in the code snippet below, a type error should occur if a user attempts to use an attribute that is incompatible with the specified tag. However, this is not currently being enforced.

// Should throw an error in the `href`
<Component as="button" href="www.google.com" />

There is this really good article that talks about How to Build Strongly Typed Polymorphic Components

Here is a PR that serves as an example of how to implement this.

Components with PolymorphicProps

Preview Give feedback
  1. role: dev 🤖
    guidari

Components that could use PolymorphicProps

Preview Give feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🪆 Needs Refined
Status: Todo
Development

No branches or pull requests

1 participant