const x: { t: 'A', foo: string } | { t: 'B', bar: string } = /*...*/ return x.t === 'A' ? x.foo : x.bar