Unions and Indexing 10 exercises

Understand The Terminology Around Unions

We're going to discuss some terminology in this exercise.

There are three types in this example:

type A =
| {
type: "a";
a: string;
| {
type: "b";
b: string;
| {
type: "c";
c: string;
type B = "a" | "b" | "c";
enum C = {
A = "a",
B = "b",
C = "

Loading exercise


0:00 This exercise is a little bit different. We're going to be talking about some terminology. We have three types here, A, B, and C. One of these is a discriminated union, one of them is an enum, and one of them is a union type. You have to work out which is which. Once you've figured out in your own head, have a look at the solution and see if you were right.