'Typescript ternary operation with assigment

const fn = (condition: boolean) => condition ? {a: ""} : {b: ""}

I have trouble with understanding why return type of fn is:

{
    a: string;
    b?: undefined;
} | {
    b: string;
    a?: undefined;
}

but not

{
    a: string;
} | {
    b: string;
}

https://www.typescriptlang.org/play?ts=4.3.5#code/FAYw9gdgzgLgBAMwnAvHAFOCATAljXSALjgCMwwAbAUwEMIBKVAPjizwMjgH44BvWiQBEQgL5wSfUsLHAgA



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source