Mapped Types 9 exercises

Transform an Object into a Union of Template Literals

In order to really hammer home the technique of working with mapped types, this exercise will be similar to the last one.

We start with this FruitMap interface and a TransformedFruit type:

interface FruitMap {
apple: "red";
banana: "yellow";
orange: "orange";
type TransformedFr

Loading exercise


0:00 This exercise is pretty similar to the previous exercise, actually. I really want to hammer this home, this technique. You're actually going to be building up from a lower point here.

0:08 We want to take this FruitMap and turn it into a template literal, which is a union of the keys and the values. Instead of a tuple, it's now going to be a template literal.

0:18 That's your job, is to find out, with reference to the previous exercise, how to transform this into this union.