Function Overloads 8 exercises
Problem

Function Overloads vs. Conditional Types

Let's look at the youSayGoodbyeISayHello problem that we've seen before:

export const youSayGoodbyeISayHello = (greeting: "goodbye" | "hello") => {
  return greeting === "goodbye" ? "hello" : "goodbye";
};

The function takes in a greeting of "goodbye" or "hello", then retur

Loading exercise

Transcript

0:00 Let's now look at this problem, which we've also seen before, the youSayGoodbye and ISayHello function. We're taking in a greeting of goodbye or hello, and then we're returning the correct greeting based on what's passed in.

0:12 You can see here that result youSayGoodbyeISayHello should be goodbye because we're passing in hello, but, in fact, it's goodbye or hello. The same thing is 1 down here.

0:23 Your job is to figure out how we can solve this one, which we previously solved with conditional types with function overloads.