Skip to content

How to specify that property is enum? #151

Discussion options

You must be logged in to vote

Once the build is complete, the code only has access to the javascript side of things. Unf, when you build enums, you only have access to their actual values.

For the way this is written now and without adding any extra layers, the r2wc type for PillSize would be "number" and the usage for a "compact" size would look like <my-pill size="0"></my-pill>.

If you can change your PillSize to have human-readable values like below, then you could use strings that make more sense.

export declare enum PillSize {
    compact = "compact",
    regular = "regular",
    large = "large"
}

Another thing I've done in cases like this is to wrap the component in a "web component compatibility layer". Essenti…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by christopherjbaker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants