From b69652b137c280b16f7325b8dedd3bf029339f27 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 5 Oct 2017 09:01:39 -0700 Subject: [PATCH] Set symbol on union of spreads Previously, it was only set on the top-level type, and only if that top-level type was an object type. Now it uses `forEachType` to set the symbol on every object type in the union as well, if `getSpreadType` returns a union. --- src/compiler/checker.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fbe192c5629..d7585bd6e9a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13917,13 +13917,15 @@ namespace ts { if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType()); } - if (spread.flags & TypeFlags.Object) { - // only set the symbol and flags if this is a (fresh) object type - spread.flags |= propagatedFlags; - spread.flags |= TypeFlags.FreshLiteral; - (spread as ObjectType).objectFlags |= ObjectFlags.ObjectLiteral; - spread.symbol = node.symbol; - } + // only set the symbol and flags if this is a (fresh) object type + forEachType(spread, t => { + if (t.flags & TypeFlags.Object) { + t.flags |= propagatedFlags; + t.flags |= TypeFlags.FreshLiteral; + (t as ObjectType).objectFlags |= ObjectFlags.ObjectLiteral; + t.symbol = node.symbol + } + }); return spread; }