Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
2 replies
nvegater

Use Enum Values from backend in the Frontend

I'm using this enum in my backend:
export const VideoYouthProtectionEnum = {
    Zero: 'zero',
    Six: 'six',
    Twelve: 'twelve',
    Sixteen: 'sixteen',
    Eighteen: 'eighteen',
    NotSet: 'notSet'
} as const;

I understand I can infer the types of enums with trpc and use those types in the Frontend like this:

type YouthProtection = RouterInputs['api']['update']['payload']['youthProtection'].

I would like to understand if there is a way to use the inferred enum as a Value in the frontend, something like this:

YouthProtection.Zero
Was this page helpful?