'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;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
