From 14590f1884c43966c62eb2016845631e7149df5b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 17 Dec 2017 20:27:04 -0800 Subject: [PATCH] Move JsxAttributes and MarkerType from TypeFlags to ObjectFlags --- src/compiler/checker.ts | 12 ++++++------ src/compiler/types.ts | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 47cc3bbab1f..6f52fcbdbf1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9656,7 +9656,7 @@ namespace ts { function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { - const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes); + const isComparingJsxAttributes = !!(getObjectFlags(source) & ObjectFlags.JsxAttributes); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; @@ -10031,7 +10031,7 @@ namespace ts { } else { if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target && - !(source.flags & TypeFlags.MarkerType || target.flags & TypeFlags.MarkerType)) { + !(getObjectFlags(source) & ObjectFlags.MarkerType || getObjectFlags(target) & ObjectFlags.MarkerType)) { // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. @@ -10245,7 +10245,7 @@ namespace ts { } function hasCommonProperties(source: Type, target: Type) { - const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes); + const isComparingJsxAttributes = !!(getObjectFlags(source) & ObjectFlags.JsxAttributes); for (const prop of getPropertiesOfType(source)) { if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { return true; @@ -10489,7 +10489,7 @@ namespace ts { // type, and flag the result as a marker type reference. function getMarkerTypeReference(type: GenericType, source: TypeParameter, target: Type) { const result = createTypeReference(type, map(type.typeParameters, t => t === source ? target : t)); - result.flags |= TypeFlags.MarkerType; + result.objectFlags |= ObjectFlags.MarkerType; return result; } @@ -14983,8 +14983,8 @@ namespace ts { */ function createJsxAttributesType(symbol: Symbol, attributesTable: UnderscoreEscapedMap) { const result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.flags |= TypeFlags.JsxAttributes | TypeFlags.ContainsObjectLiteral; - result.objectFlags |= ObjectFlags.ObjectLiteral; + result.flags |= TypeFlags.ContainsObjectLiteral; + result.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.JsxAttributes; return result; } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2ba528b59f8..ee64bfe6e5f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3367,8 +3367,7 @@ namespace ts { ContainsAnyFunctionType = 1 << 26, // Type is or contains the anyFunctionType NonPrimitive = 1 << 27, // intrinsic object type /* @internal */ - JsxAttributes = 1 << 28, // Jsx attributes type - MarkerType = 1 << 29, // Marker type used for variance probing + GenericMappedType = 1 << 29, // Flag used by maybeTypeOfKind /* @internal */ Nullable = Undefined | Null, @@ -3406,7 +3405,6 @@ namespace ts { /* @internal */ PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | ContainsAnyFunctionType, /* @internal */ - GenericMappedType = MarkerType, // Flag used by maybeTypeOfKind } export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; @@ -3465,6 +3463,8 @@ namespace ts { EvolvingArray = 1 << 8, // Evolving array type ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties ContainsSpread = 1 << 10, // Object literal contains spread operation + JsxAttributes = 1 << 11, // Jsx attributes type + MarkerType = 1 << 12, // Marker type used for variance probing ClassOrInterface = Class | Interface }