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

"as" polymorphic prop returns incorrect type #1414

Open
EricWVGG opened this issue May 31, 2024 · 0 comments
Open

"as" polymorphic prop returns incorrect type #1414

EricWVGG opened this issue May 31, 2024 · 0 comments
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized

Comments

@EricWVGG
Copy link

EricWVGG commented May 31, 2024

Environment

  • Linaria version: 6.2
  • Node.js version: 18.19.0
  • OS: MacOS 14.5
  • "next-with-linaria": "^0.7.0"

Description

I'm migrating from Styled-Components to Linaria. So far pretty great! However I think I've found a minor typing issue.

I have a Button component that I frequently use as an anchor tag thusly…

<Button onClick={doSomething} >This is rendered as a button tag</Button>
<Button as="a" href="/" >This is rendered as an anchor tag</Button>

I was pleased to see that this basically works — the browser does correctly render an <a> tag in the markup, the link functions, cool. However, Typescript complains about the href attribute. The type of the component is still returned as StyledComponent<ClassAttributes<HTMLButtonElement> & ButtonHTMLAttributes<HTMLButtonElement> & Record<never, unknown>>

@EricWVGG EricWVGG added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels May 31, 2024
@github-actions github-actions bot added needs: triage 🏷 Issue needs to be checked and prioritized and removed needs: triage 🏷 Issue needs to be checked and prioritized labels May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized
Projects
None yet
Development

No branches or pull requests

1 participant