Type guards and discriminated unions: discriminant loss with optional properties
When a type guard predicated on a discriminated union includes an optional discriminant, the control‑flow analysis may discard the discriminant tag, causing the narrowed type to collapse to `never` or revert to the full union without an apparent trigger. This behavior interferes with reliable type narrowing in libraries that model optional state through disc