Typing Data Attributes with Discriminated Union #4862
Unanswered
rawrmonstar
asked this question in
Q&A
Replies: 1 comment
-
I don't think it's possible, sorry. We have a number of interfaces that must extend I switched some of our per-element types ( FWIW, React & other JSX libs should generally work the same so if you do find a solution that applies to them, try it & let us know if we need to adjust something. |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
I'm exploring heavily using data attributes, mostly for applying styles, but I would like to type them. Is it possible to type data attributes such that they are a discriminated union?
I have two attributes:
data-text-variant
anddata-text-size
ifdata-text-variant
is"body"
data-text-size
accepts one set of values, if"heading"
it takes a different set of values.Since HTMLAttributes are an interface and we add typings through interface merging I'm not seeing a way to actually do this...
Has anyone done something like this before? How did you?
Beta Was this translation helpful? Give feedback.
All reactions