TypeScript: Control flow analysis for destructured discriminated unions
Very nice!The very, very related thing I found myself wishing I had just today is the ability to destructure discriminated union fields which only exist on one component type of the union.As an example, with the following type system:    type Output = OutputExists | OutputDoesntExist;
    interface OutputExists { exists: true, url: string };
    interface OutputDoesntExist { exists: false };

The ability to destructure like:    const f = ({ exists, url }: Output) => {}

Such that, at the time of destructuring:    exists: true | false
    url: string | undefined

I believe, with this PR, if we re-structured the types above to:    interface OutputDoesntExist { exists: false, url: undefined };

That destructuring would be possible, with all the control flow analysis necessary to make it useful. Today, even that wouldn't be possible, so definitely excited for this change.But, I'm curious if anyone knows if this change can extend to situations where a field isn't even defined in one of the unions, and the compiler can just insert an undefined type for those fields. Or, maybe this would have some unresolveable side-effects I'm not considering.