From 58d6156c69e08e8479e3102d90cccc34a0e9d832 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 20 Oct 2016 17:00:07 -0700 Subject: [PATCH] Move ObjectLiteralPatternWithComputedProperties to ObjectFlags --- src/compiler/checker.ts | 10 ++++------ src/compiler/types.ts | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 843a21cbae3..ae99919fabe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3222,7 +3222,7 @@ namespace ts { result.pattern = pattern; } if (hasComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + result.objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties; } return result; } @@ -6734,8 +6734,7 @@ namespace ts { } function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { - if (maybeTypeOfKind(target, TypeFlags.ObjectType) && - (!(target.flags & TypeFlags.ObjectType) || !(target as ObjectType).isObjectLiteralPatternWithComputedProperties)) { + if (maybeTypeOfKind(target, TypeFlags.ObjectType) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { for (const prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { if (reportErrors) { @@ -10599,8 +10598,7 @@ namespace ts { patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && - !(contextualType.flags & TypeFlags.ObjectType && (contextualType as ObjectType).isObjectLiteralPatternWithComputedProperties)) { + else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. const impliedProp = getPropertyOfType(contextualType, member.name); @@ -10668,7 +10666,7 @@ namespace ts { result.flags |= TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); result.objectFlags |= ObjectFlags.ObjectLiteral; if (patternWithComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + result.objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties; } if (inDestructuringPattern) { result.pattern = node; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 551f8b8697e..9d6108f27fb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2664,6 +2664,7 @@ namespace ts { Instantiated = 1 << 5, // Instantiated anonymous type ObjectLiteral = 1 << 6, // Originates in an object literal EvolvingArray = 1 << 7, // Evolving array type + ObjectLiteralPatternWithComputedProperties = 1 << 8, // Object literal pattern with computed properties } // Properties common to all types @@ -2703,7 +2704,6 @@ namespace ts { // Object types (TypeFlags.ObjectType) export interface ObjectType extends Type { objectFlags: ObjectFlags; - isObjectLiteralPatternWithComputedProperties?: boolean; } // Class and interface types (TypeFlags.Class and TypeFlags.Interface)