Start here. This is the direct spoken answer to practice first.
Why this question matters
Several independent booleans can describe combinations the product can never mean, such as loading and successful with no data at the same time. A discriminated union makes each valid state explicit.
I can model the state as variants such as { status: 'idle' }, { status: 'loading' }, { status: 'success', data }, and { status: 'error', error }. Switching on status narrows the fields available in each branch, so the success branch can read data and the error branch can read the error. This removes invalid combinations created by unrelated isLoading, data, and error values. It also makes the render logic reflect the actual state machine.