Exercise: Model Structured API States with Discriminated Unions
Master discriminated unions by modeling a real-world API response with full exhaustiveness and type safety.
We’ve seen how discriminated unions give us precision. Now let’s take that precision and put it to work.
The problem
We’re building a frontend that calls an API to fetch user profile data. The server doesn’t just return raw values—it sends structured responses that reflect the state of the request. This is a perfect use case for discriminated unions.
In this exercise, ...
Access this course and 1400+ top-rated courses and projects.