The VariantProps generic type should return variants of an extended component
Is your feature request related to a problem? Please describe. The VariantProps generic type should return variants of an extended component
Describe the solution you'd like The VariantProps generic type does not return variants of an extended component
export const Box = styled("div", {
display: "block",
variants: {
inline: {
true: {
display: "inline-block"
}
}
},
defaultVariants: {
inline: true
}
});
const Container = styled(Box, {
display: "block"
});
// Is an empty object
type ContainerVariants = VariantProps<typeof Container>;
Describe alternatives you've considered We could do this instead
type ContainerVariants = VariantProps<typeof Box>;
A knock-on effect of this is that you can't use all keys in defaultVariants for components that have been extended.
To use your example, the following would throw an error claiming inline doesn't exist:
const Container = styled(Box, {
display: "block"
defaultVariants: { inline: true }
});
This is a good point. Thanks for raising. We had reached some TS limitations when we built this initially. We'll have to give it another go.
Any update?