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.
This commit is contained in:
Nathan Shively-Sanders 2017-10-05 09:01:39 -07:00
parent 648bd6e9e0
commit b69652b137

View File

@ -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;
}