Skip to content

Generate types similar to RecipeVariants, but with string literals #1089

Answered by daformat
laura-asimov asked this question in Q&A
Discussion options

You must be logged in to vote

RecipeVariants includes undefined, here's what I do when I need something like this:

export type MaybeTextVariants = RecipeVariants<typeof textRecipe>;
export type TextVariants = Exclude<MaybeTextVariants, undefined>;
export type TextColor = TextVariants['color'];

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!

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@laura-asimov
Comment options

@laura-asimov
Comment options

@askoufis
Comment options

Answer selected by laura-asimov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants