Skip to content

Commit b9efe3e

Browse files
committed
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`.
1 parent 5e20c1c commit b9efe3e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7640,11 +7640,11 @@ namespace ts {
76407640
if (members.has(leftProp.name)) {
76417641
const rightProp = members.get(leftProp.name);
76427642
const rightType = getTypeOfSymbol(rightProp);
7643-
if (maybeTypeOfKind(rightType, TypeFlags.Undefined) || rightProp.flags & SymbolFlags.Optional) {
7643+
if (rightProp.flags & SymbolFlags.Optional) {
76447644
const declarations: Declaration[] = concatenate(leftProp.declarations, rightProp.declarations);
76457645
const flags = SymbolFlags.Property | (leftProp.flags & SymbolFlags.Optional);
76467646
const result = createSymbol(flags, leftProp.name);
7647-
result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, TypeFacts.NEUndefined)]);
7647+
result.type = getUnionType([getTypeOfSymbol(leftProp), rightType]);
76487648
result.leftSpread = leftProp;
76497649
result.rightSpread = rightProp;
76507650
result.declarations = declarations;

0 commit comments

Comments
 (0)