-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Complex union type in Polymorphic components #11880
Comments
I have this error as well. The prop spreading is what inflates the number of type variations that TS needs to evaluate and check. |
So if you dont spread it, the TS error is gone? If yes, do you have a basic example of a component |
I believe so, yes. I encountered this a while ago and the only way I was able to get the error to go away was by removing the prop spreading when destructuring |
In -type Props<Tag extends HTMLTag> = Polymorphic<{ as: Tag }>;
+type Props<Tag extends HTMLTag = "button"> = Polymorphic<{ as: Tag }>; I think this is why Typescript complains about too complex union type. By doing this you will see that |
@walmartwarlord does Armand's solution work for you? |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Getting a TS error in a fresh project with a simple Polymorphic component:
What's the expected result?
It should not have any TypeScript error as it does have a default value.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-e3ih6w?file=src%2Fpages%2Findex.astro
Participation
The text was updated successfully, but these errors were encountered: