Skip to content
Advertisement

How can I conditionally add several values to a type?

I have this type:

JavaScript

I don’t want those last two to be in the type when a condition is met. How can I conditionally add those last two values only when the condition is met?

This was my approach (but it’s not working):

JavaScript

Advertisement

Answer

You need to check if const’s type extends 'production':

JavaScript

Playground

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement