Move JsxAttributes and MarkerType from TypeFlags to ObjectFlags

This commit is contained in:
Anders Hejlsberg
2017-12-17 20:27:04 -08:00
parent f59e2e6331
commit 14590f1884
2 changed files with 9 additions and 9 deletions
+6 -6
View File
@@ -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 && (<TypeReference>source).target === (<TypeReference>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<Symbol>) {
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;
}
}
+3 -3
View File
@@ -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
}