Retain undefined in spreads w/strictNullChecks
Previously, both optional and `| undefined` caused spread properties to combine with preceding properties and drop the `undefined`. Now, with strictNullChecks, optional and `| undefined` properties still combine with preceding properties but don't drop the `undefined`.
This commit is contained in:
parent
5e20c1ce11
commit
b9efe3e700
1 changed files with 2 additions and 2 deletions
|
@ -7640,11 +7640,11 @@ namespace ts {
|
|||
if (members.has(leftProp.name)) {
|
||||
const rightProp = members.get(leftProp.name);
|
||||
const rightType = getTypeOfSymbol(rightProp);
|
||||
if (maybeTypeOfKind(rightType, TypeFlags.Undefined) || rightProp.flags & SymbolFlags.Optional) {
|
||||
if (rightProp.flags & SymbolFlags.Optional) {
|
||||
const declarations: Declaration[] = concatenate(leftProp.declarations, rightProp.declarations);
|
||||
const flags = SymbolFlags.Property | (leftProp.flags & SymbolFlags.Optional);
|
||||
const result = createSymbol(flags, leftProp.name);
|
||||
result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, TypeFacts.NEUndefined)]);
|
||||
result.type = getUnionType([getTypeOfSymbol(leftProp), rightType]);
|
||||
result.leftSpread = leftProp;
|
||||
result.rightSpread = rightProp;
|
||||
result.declarations = declarations;
|
||||
|
|
Loading…
Reference in a new issue