Skip to content
Medium
Unions & guards

Discriminated response

Use a discriminated union for API responses and implement an exhaustive handler that returns a string message for any variant.

Starter provided. Feel free to modify.

Solution

Loading...
Run your code to see output and diagnostics.

Built by Antigravity. The source code is available on GitHub.