@@ -4523,7 +4523,7 @@ namespace ts {
4523
4523
t;
4524
4524
}
4525
4525
4526
- function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: string) {
4526
+ function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: string): Symbol {
4527
4527
const types = containingType.types;
4528
4528
let props: Symbol[];
4529
4529
// Flags we want to propagate to the result if they exist in all source symbols
@@ -5914,11 +5914,12 @@ namespace ts {
5914
5914
}
5915
5915
if (leftProp.name in members) {
5916
5916
const rightProp = members[leftProp.name];
5917
- if (rightProp.flags & SymbolFlags.Optional) {
5917
+ const rightType = getTypeOfSymbol(rightProp);
5918
+ if (maybeTypeOfKind(rightType, TypeFlags.Undefined) || rightProp.flags & SymbolFlags.Optional) {
5918
5919
const declarations: Declaration[] = concatenate(leftProp.declarations, rightProp.declarations);
5919
5920
const flags = SymbolFlags.Property | SymbolFlags.Transient | (leftProp.flags & SymbolFlags.Optional);
5920
5921
const result = <TransientSymbol>createSymbol(flags, leftProp.name);
5921
- result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeOfSymbol(rightProp )]);
5922
+ result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, TypeFacts.NEUndefined )]);
5922
5923
result.leftSpread = leftProp;
5923
5924
result.rightSpread = rightProp;
5924
5925
result.declarations = declarations;
0 commit comments