Having trouble getting typescript working with modified components #3748
Unanswered
AlexFrazer
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Here's the general idea: I want to use a headless ui component and simply apply the classnames which I see fit, while supporting all the features of headlessui, including the
as
property which I find to be very helpful for my use caseI was running into a problem where I believe the problem was that
className
is potentially not there, becauseElementType
could extendComponentType
andComponentType
does not necessarily extend{ className?: string }
. This is reinforced by finding this in the type definitions:So, I figured the problem is that I need to first check for the className before adding "my own".
However, it seems like this isn't working either, saying that
props.className
is going to resolve tounknown
.I'm looking for a good solution to this, but it seems like a fairly common use case (basically just extending the existing system). Has anyone already solved this problem? If so, how?
Beta Was this translation helpful? Give feedback.
All reactions