Challenges 4 exercises
Problem

Transform an Object into a Discriminated Union

This exercise begins with this Attributes interface and an empty MutuallyExclusive<T>:


interface Attributes {
id: string;
email: string;
username: string;
}
type MutuallyExclusive<T> = unknown;

Challenge

Your challenge is to update MutuallyExclusive to be a type helper

Loading exercise

Transcript

0:00 This next challenge takes an object, takes in any old object you can pass in, and turns it into a discriminated union of all of the individual properties of that object. Attributes here, what we should end up with is id or email or username.

0:19 This is a cool challenge. It tests your brain a little bit, but there's nothing new in here. Nothing you haven't seen before. All we want to do is turn MutuallyExclusive into this type helper, which can transform this.

0:32 You can use ExclusiveAttributes here to check how you're doing. Good luck.