A discriminated union that the compiler narrowed for free

A result type with a literal discriminant, and every branch typed without a single assertion.

type Result =
  | { ok: true;  data: Order }
  | { ok: false; error: string; retryable: boolean }

if (result.ok) {
  result.data      // Order
  result.error     // error: does not exist
} else {
  result.retryable // boolean
}

The discriminant has to be a literal type on every member, and a member missing it silently disables narrowing for the whole union — which produces errors that read as if the union itself is wrong. Using a boolean as the discriminant works and reads worse than a string once there are three or more cases.