Generate types similar to RecipeVariants, but with string literals #1089
Answered
by
daformat
laura-asimov
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
daformat
May 12, 2023
Replies: 1 comment 3 replies
-
export type MaybeTextVariants = RecipeVariants<typeof textRecipe>;
export type TextVariants = Exclude<MaybeTextVariants, undefined>;
export type TextColor = TextVariants['color']; I think you can go with just |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
laura-asimov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RecipeVariants
includesundefined
, here's what I do when I need something like this:I think you can go with just
Exclude<MaybeTextVariants, undefined>
in your case? The types shown in intellisense are confusing, but they are working as expected, hope this helps!