Syled generic component with Typescript #4204
Unanswered
julienmonnard
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I'm coming to you for help, as I am not sure if this is a bug, a limitation or just me that is not doing things correctly 🙂
Basically, I have a React component, which takes advantage of generic types, like this:
This approach allows me to have the types for
row
dynamically infered depending on the props I give to myTable
component.So when I use it like this:
The problem is, as soon as I use
styled
around theTable
component, I lose that inferenceAnd if I remove the
extends AnyObject
from myTable
component like this:Then
row
will be infered asunknown
Can somebody help me why this is happening, and if this can be solved somehow?
I made a small repro on TS Playground with all the necessary code.
Beta Was this translation helpful? Give feedback.
All reactions