Conditional Types and Infer 10 exercises
Problem

Add Conditional Logic to a Type Helper

In this exercise we're going to add something on to the type helper pattern.

Since we know that we can return types from a type helper, it makes sense that we could include conditional logic that will return something different based on what gets passed in.

Challenge

Your challenge is to add c

Loading exercise

Transcript

0:00 We're now going to take that type helper pattern that we had before and add something else to it. Now that we know that we can return things from a function, it makes sense that we could do if else logic within that function and return something different based on what gets passed in.

0:15 This type function that we're going to create, it's going to say YouSayGoodbyeAndISayHello. When we pass in hello, we should expect goodbye. When we pass in goodbye, we should expect hello to come back.

0:28 That's your goal, is to try and find some sort of tool within TypeScript to let you do that. I'll give you a clue. It's called conditional types. Good luck.