Just recently, I defined a type as follows-
interface SomeType {
property: {
a: number;
b: string;
} | undefined;
}
However, upon saving the type, vscode (or maybe prettier) changes it to-
interface SomeType {
property:
| {
a: number;
b: string;
}
| undefined;
}
As you can see, there is an extra |
symbol added after the property
key. What does this additional symbol signify? Can anyone explain this behavior?
Note: This adjustment only occurs when defining
. If property: {a: number; b: string;} | undefined;
| undefined
is not included, everything remains unchanged.