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
1 of 13 tasks
guidari opened this issue Dec 26, 2024 · 0 comments
Open
1 of 13 tasks

Building Strongly Typed Polymorphic Components #18275

guidari opened this issue Dec 26, 2024 · 0 comments
Labels
afrohacks See https://ibm.biz/afrohacks-hackathon area: typescript needs: community contribution Due to roadmap and resource availability, we are looking for outside contributions on this issue. planning: umbrella Umbrella issues, surfaced in Projects views role: dev 🤖

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
  2. role: dev 🤖
    guidari
  3. role: dev 🤖
    guidari
  4. role: dev 🤖
    guidari

Components that could use PolymorphicProps

Preview Give feedback
@guidari guidari moved this to 🪆 Needs Refined in Design System Dec 26, 2024
@guidari guidari moved this from 🪆 Needs Refined to 🏗 In Progress in Design System Jan 15, 2025
@guidari guidari removed the status in Design System Jan 15, 2025
@guidari guidari moved this to 🏗 In Progress in Design System Jan 15, 2025
@guidari guidari added needs: community contribution Due to roadmap and resource availability, we are looking for outside contributions on this issue. afrohacks See https://ibm.biz/afrohacks-hackathon planning: umbrella Umbrella issues, surfaced in Projects views labels Jan 15, 2025
@guidari guidari added this to Roadmap Jan 15, 2025
@github-project-automation github-project-automation bot moved this to Triage in Roadmap Jan 15, 2025
@guidari guidari moved this from Triage to Next ➡ in Roadmap Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
afrohacks See https://ibm.biz/afrohacks-hackathon area: typescript needs: community contribution Due to roadmap and resource availability, we are looking for outside contributions on this issue. planning: umbrella Umbrella issues, surfaced in Projects views role: dev 🤖
Projects
Status: 🏗 In Progress
Status: Todo
Status: Next ➡
Development

No branches or pull requests

1 participant