The css
prop is not attached to a type of props if it is a disjoint union type on className
field.
#3185
Labels
css
prop is not attached to a type of props if it is a disjoint union type on className
field.
#3185
Current behavior:
WithConditionalCSSProp<P>
doesn't create thecss
prop ifP
is a disjoin union type onclassName
field. Therefore we can't use some components optionally takingclassName
field, likeLink
of wouter.To reproduce:
Since it's not a problem inherent in emotion or react but a problem of treating union types, we can reproduce it with following simplified snippet.
typescript playground
However, It's always good to have detailed reproduction. Here is the case I encountered.
Expected behavior:
I think it might be more accurate to add
css
prop to branches where properclassName
field is available. Therefore pass type check for components optionally takingclassName
like wouter's.I suggest following as a fix:
Environment information:
react
version: 18.2.0@emotion/react
version: 11.11.4The text was updated successfully, but these errors were encountered: