An interface where four properties are optional describes many states that cannot occur, and the type system cannot help with any of them.
// every combination is representable, including nonsense
interface Result {
loading?: boolean
data?: Order
error?: Error
}
// only three states exist, and the compiler enforces it
type Result =
| { status: 'loading' }
| { status: 'success'; data: Order }
| { status: 'error'; error: Error }
if (r.status === 'success') { r.data } // narrowed
Narrowing on the discriminant is what makes the second version worth the extra characters — accessing data is only legal in the branch where it exists, so the null check disappears rather than being enforced by convention. It also makes the impossible states unrepresentable, which is the phrase for this and is accurate: loading and error at once cannot be constructed.