From b9efe3e700deb7f4558caae0ed41ac143c2b3663 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 18 May 2017 13:57:24 -0700 Subject: [PATCH] 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`. --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dde8033d1e..e4ea3740a6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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;