Type Transformations Workshop (9 exercises)
Problem

Create a Union From an Object's Values

This exercise starts with our programModeEnumMap that includes the as const annotation.

This time, we want to index into programModeEnumMap and pull out a union type from it. More specifically, we want the union to be "1on1" | "selfDirected" | "planned1on1" | "plannedSelfDirected" as seen in the test:

Challenge

Starting with this IndividualProgram type:

Your challenge is to replace the unknown with a value that results in the union above.

This is going to be simpler than you might think, but it does introduce something new!

Transcript

[0:00] Here's another problem that starts with our programModeEnumMap. We've got our as const declaration here, which is great. We've now got all the values available to us, but we want to index into it and grab out a union type from it.
[0:20] We want 1on1 or selfDirected or planned1on1 or plannedSelfDirected. We want this one or this one or this one or this one, basically anything that's not a group activity, for instance, so all of these are 1on1.

[0:35] We need to somehow do that within this value here, so we need to replace this unknown with the thing that we think is going to work here. Again, this one is slightly simpler than you think it's going to be, but it also does introduce something new.

[0:50] Good luck with this. This one is quite tricky.