Skip to content

Commit 7facab0

Browse files
committed
Rename TypeFlags.ObjectType to TypeFlags.Object
1 parent f05ecec commit 7facab0

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

src/compiler/checker.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ namespace ts {
539539
}
540540

541541
function getObjectFlags(type: Type): ObjectFlags {
542-
return type.flags & TypeFlags.ObjectType ? (<ObjectType>type).objectFlags : 0;
542+
return type.flags & TypeFlags.Object ? (<ObjectType>type).objectFlags : 0;
543543
}
544544

545545
function isGlobalSourceFile(node: Node) {
@@ -1594,7 +1594,7 @@ namespace ts {
15941594
}
15951595

15961596
function createObjectType(objectFlags: ObjectFlags, symbol?: Symbol): ObjectType {
1597-
const type = <ObjectType>createType(TypeFlags.ObjectType);
1597+
const type = <ObjectType>createType(TypeFlags.Object);
15981598
type.objectFlags = objectFlags;
15991599
type.symbol = symbol;
16001600
return type;
@@ -3600,7 +3600,7 @@ namespace ts {
36003600
}
36013601

36023602
function isConstructorType(type: Type): boolean {
3603-
return type.flags & TypeFlags.ObjectType && getSignaturesOfType(type, SignatureKind.Construct).length > 0;
3603+
return type.flags & TypeFlags.Object && getSignaturesOfType(type, SignatureKind.Construct).length > 0;
36043604
}
36053605

36063606
function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments {
@@ -3637,7 +3637,7 @@ namespace ts {
36373637
return unknownType;
36383638
}
36393639
const baseConstructorType = checkExpression(baseTypeNode.expression);
3640-
if (baseConstructorType.flags & TypeFlags.ObjectType) {
3640+
if (baseConstructorType.flags & TypeFlags.Object) {
36413641
// Resolving the members of a class requires us to resolve the base class of that class.
36423642
// We force resolution here such that we catch circularities now.
36433643
resolveStructuredTypeMembers(<ObjectType>baseConstructorType);
@@ -3678,7 +3678,7 @@ namespace ts {
36783678
function resolveBaseTypesOfClass(type: InterfaceType): void {
36793679
type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray;
36803680
const baseConstructorType = <ObjectType>getBaseConstructorTypeOfClass(type);
3681-
if (!(baseConstructorType.flags & TypeFlags.ObjectType)) {
3681+
if (!(baseConstructorType.flags & TypeFlags.Object)) {
36823682
return;
36833683
}
36843684
const baseTypeNode = getBaseTypeNodeOfClass(type);
@@ -4350,7 +4350,7 @@ namespace ts {
43504350
constructSignatures = getDefaultConstructSignatures(classType);
43514351
}
43524352
const baseConstructorType = getBaseConstructorTypeOfClass(classType);
4353-
if (baseConstructorType.flags & TypeFlags.ObjectType) {
4353+
if (baseConstructorType.flags & TypeFlags.Object) {
43544354
members = createSymbolTable(getNamedMembers(members));
43554355
addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType));
43564356
}
@@ -4369,7 +4369,7 @@ namespace ts {
43694369

43704370
function resolveStructuredTypeMembers(type: StructuredType): ResolvedType {
43714371
if (!(<ResolvedType>type).members) {
4372-
if (type.flags & TypeFlags.ObjectType) {
4372+
if (type.flags & TypeFlags.Object) {
43734373
if ((<ObjectType>type).objectFlags & ObjectFlags.Reference) {
43744374
resolveTypeReferenceMembers(<TypeReference>type);
43754375
}
@@ -4392,7 +4392,7 @@ namespace ts {
43924392

43934393
/** Return properties of an object type or an empty array for other types */
43944394
function getPropertiesOfObjectType(type: Type): Symbol[] {
4395-
if (type.flags & TypeFlags.ObjectType) {
4395+
if (type.flags & TypeFlags.Object) {
43964396
return resolveStructuredTypeMembers(<ObjectType>type).properties;
43974397
}
43984398
return emptyArray;
@@ -4401,7 +4401,7 @@ namespace ts {
44014401
/** If the given type is an object type and that type has a property by the given name,
44024402
* return the symbol for that property. Otherwise return undefined. */
44034403
function getPropertyOfObjectType(type: Type, name: string): Symbol {
4404-
if (type.flags & TypeFlags.ObjectType) {
4404+
if (type.flags & TypeFlags.Object) {
44054405
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
44064406
const symbol = resolved.members[name];
44074407
if (symbol && symbolIsValue(symbol)) {
@@ -4574,7 +4574,7 @@ namespace ts {
45744574
*/
45754575
function getPropertyOfType(type: Type, name: string): Symbol {
45764576
type = getApparentType(type);
4577-
if (type.flags & TypeFlags.ObjectType) {
4577+
if (type.flags & TypeFlags.Object) {
45784578
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
45794579
const symbol = resolved.members[name];
45804580
if (symbol && symbolIsValue(symbol)) {
@@ -5273,7 +5273,7 @@ namespace ts {
52735273
return arity ? emptyGenericType : emptyObjectType;
52745274
}
52755275
const type = getDeclaredTypeOfSymbol(symbol);
5276-
if (!(type.flags & TypeFlags.ObjectType)) {
5276+
if (!(type.flags & TypeFlags.Object)) {
52775277
error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name);
52785278
return arity ? emptyGenericType : emptyObjectType;
52795279
}
@@ -5453,7 +5453,7 @@ namespace ts {
54535453
const len = typeSet.length;
54545454
const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type);
54555455
if (index < 0) {
5456-
if (!(flags & TypeFlags.ObjectType && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous &&
5456+
if (!(flags & TypeFlags.Object && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous &&
54575457
type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && containsIdenticalType(typeSet, type))) {
54585458
typeSet.splice(~index, 0, type);
54595459
}
@@ -6060,7 +6060,7 @@ namespace ts {
60606060
if (type.flags & TypeFlags.TypeParameter) {
60616061
return mapper(<TypeParameter>type);
60626062
}
6063-
if (type.flags & TypeFlags.ObjectType) {
6063+
if (type.flags & TypeFlags.Object) {
60646064
if ((<ObjectType>type).objectFlags & ObjectFlags.Anonymous) {
60656065
// If the anonymous type originates in a declaration of a function, method, class, or
60666066
// interface, in an object type literal, or in an object literal expression, we may need
@@ -6147,7 +6147,7 @@ namespace ts {
61476147
}
61486148

61496149
function getTypeWithoutSignatures(type: Type): Type {
6150-
if (type.flags & TypeFlags.ObjectType) {
6150+
if (type.flags & TypeFlags.Object) {
61516151
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
61526152
if (resolved.constructSignatures.length) {
61536153
const result = <ResolvedType>createObjectType(ObjectFlags.Anonymous, type.symbol);
@@ -6457,7 +6457,7 @@ namespace ts {
64576457
if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) {
64586458
return true;
64596459
}
6460-
if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) {
6460+
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) {
64616461
const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
64626462
const related = relation[id];
64636463
if (related !== undefined) {
@@ -6657,7 +6657,7 @@ namespace ts {
66576657
// In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
66586658
// to X. Failing both of those we want to check if the aggregation of A and B's members structurally
66596659
// relates to X. Thus, we include intersection types on the source side here.
6660-
if (apparentSource.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) {
6660+
if (apparentSource.flags & (TypeFlags.Object | TypeFlags.Intersection) && target.flags & TypeFlags.Object) {
66616661
// Report structural errors only if we haven't reported any errors yet
66626662
const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & TypeFlags.Primitive);
66636663
if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) {
@@ -6668,10 +6668,10 @@ namespace ts {
66686668
}
66696669

66706670
if (reportErrors) {
6671-
if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.Primitive) {
6671+
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) {
66726672
tryElaborateErrorsForPrimitivesAndObjects(source, target);
66736673
}
6674-
else if (source.symbol && source.flags & TypeFlags.ObjectType && globalObjectType === source) {
6674+
else if (source.symbol && source.flags & TypeFlags.Object && globalObjectType === source) {
66756675
reportError(Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
66766676
}
66776677
reportRelationError(headMessage, source, target);
@@ -6681,7 +6681,7 @@ namespace ts {
66816681

66826682
function isIdenticalTo(source: Type, target: Type): Ternary {
66836683
let result: Ternary;
6684-
if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) {
6684+
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) {
66856685
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
66866686
// We have type references to same target type, see if all type arguments are identical
66876687
if (result = typeArgumentsRelatedTo(<TypeReference>source, <TypeReference>target, /*reportErrors*/ false)) {
@@ -6706,7 +6706,7 @@ namespace ts {
67066706
// index signatures, or if the property is actually declared in the object type. In a union or intersection
67076707
// type, a property is considered known if it is known in any constituent type.
67086708
function isKnownProperty(type: Type, name: string): boolean {
6709-
if (type.flags & TypeFlags.ObjectType) {
6709+
if (type.flags & TypeFlags.Object) {
67106710
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
67116711
if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) ||
67126712
resolved.stringIndexInfo ||
@@ -6734,7 +6734,7 @@ namespace ts {
67346734
}
67356735

67366736
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
6737-
if (maybeTypeOfKind(target, TypeFlags.ObjectType) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) {
6737+
if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) {
67386738
for (const prop of getPropertiesOfObjectType(source)) {
67396739
if (!isKnownProperty(target, prop.name)) {
67406740
if (reportErrors) {
@@ -7007,7 +7007,7 @@ namespace ts {
70077007
}
70087008

70097009
function propertiesIdenticalTo(source: Type, target: Type): Ternary {
7010-
if (!(source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType)) {
7010+
if (!(source.flags & TypeFlags.Object && target.flags & TypeFlags.Object)) {
70117011
return Ternary.False;
70127012
}
70137013
const sourceProperties = getPropertiesOfObjectType(source);
@@ -7903,7 +7903,7 @@ namespace ts {
79037903
}
79047904
else {
79057905
source = getApparentType(source);
7906-
if (source.flags & TypeFlags.ObjectType) {
7906+
if (source.flags & TypeFlags.Object) {
79077907
if (isInProcess(source, target)) {
79087908
return;
79097909
}
@@ -8295,7 +8295,7 @@ namespace ts {
82958295
type === falseType ? TypeFacts.FalseStrictFacts : TypeFacts.TrueStrictFacts :
82968296
type === falseType ? TypeFacts.FalseFacts : TypeFacts.TrueFacts;
82978297
}
8298-
if (flags & TypeFlags.ObjectType) {
8298+
if (flags & TypeFlags.Object) {
82998299
return isFunctionObjectType(<ObjectType>type) ?
83008300
strictNullChecks ? TypeFacts.FunctionStrictFacts : TypeFacts.FunctionFacts :
83018301
strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts;
@@ -11732,7 +11732,7 @@ namespace ts {
1173211732

1173311733
// If type has a single call signature and no other members, return that signature. Otherwise, return undefined.
1173411734
function getSingleCallSignature(type: Type): Signature {
11735-
if (type.flags & TypeFlags.ObjectType) {
11735+
if (type.flags & TypeFlags.Object) {
1173611736
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
1173711737
if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 &&
1173811738
resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
@@ -13571,7 +13571,7 @@ namespace ts {
1357113571
if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
1357213572
error(left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
1357313573
}
13574-
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
13574+
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeParameter)) {
1357513575
error(right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
1357613576
}
1357713577
return booleanType;
@@ -16478,7 +16478,7 @@ namespace ts {
1647816478
const rightType = checkNonNullExpression(node.expression);
1647916479
// unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
1648016480
// in this case error about missing name is already reported - do not report extra one
16481-
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
16481+
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeParameter)) {
1648216482
error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
1648316483
}
1648416484

@@ -19245,7 +19245,7 @@ namespace ts {
1924519245
}
1924619246

1924719247
function isFunctionType(type: Type): boolean {
19248-
return type.flags & TypeFlags.ObjectType && getSignaturesOfType(type, SignatureKind.Call).length > 0;
19248+
return type.flags & TypeFlags.Object && getSignaturesOfType(type, SignatureKind.Call).length > 0;
1924919249
}
1925019250

1925119251
function getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind {

src/compiler/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,7 +2612,7 @@ namespace ts {
26122612
Null = 1 << 12,
26132613
Never = 1 << 13, // Never type
26142614
TypeParameter = 1 << 14, // Type parameter
2615-
ObjectType = 1 << 15, // Object type
2615+
Object = 1 << 15, // Object type
26162616
Union = 1 << 16, // Union (T | U)
26172617
Intersection = 1 << 17, // Intersection (T & U)
26182618
/* @internal */
@@ -2640,13 +2640,13 @@ namespace ts {
26402640
BooleanLike = Boolean | BooleanLiteral,
26412641
EnumLike = Enum | EnumLiteral,
26422642
UnionOrIntersection = Union | Intersection,
2643-
StructuredType = ObjectType | Union | Intersection,
2643+
StructuredType = Object | Union | Intersection,
26442644
StructuredOrTypeParameter = StructuredType | TypeParameter,
26452645

26462646
// 'Narrowable' types are types where narrowing actually narrows.
26472647
// This *should* be every type other than null, undefined, void, and never
26482648
Narrowable = Any | StructuredType | TypeParameter | StringLike | NumberLike | BooleanLike | ESSymbol,
2649-
NotUnionOrUnit = Any | ESSymbol | ObjectType,
2649+
NotUnionOrUnit = Any | ESSymbol | Object,
26502650
/* @internal */
26512651
RequiresWidening = ContainsWideningType | ContainsObjectLiteral,
26522652
/* @internal */

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ namespace ts {
382382
return this.checker.getIndexTypeOfType(this, IndexKind.Number);
383383
}
384384
getBaseTypes(): ObjectType[] {
385-
return this.flags & TypeFlags.ObjectType && this.objectFlags & (ObjectFlags.Class | ObjectFlags.Interface)
385+
return this.flags & TypeFlags.Object && this.objectFlags & (ObjectFlags.Class | ObjectFlags.Interface)
386386
? this.checker.getBaseTypes(<InterfaceType><Type>this)
387387
: undefined;
388388
}

src/services/symbolDisplay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ namespace ts.SymbolDisplay {
173173
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
174174
displayParts.push(spacePart());
175175
}
176-
if (!(type.flags & TypeFlags.ObjectType && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous) && type.symbol) {
176+
if (!(type.flags & TypeFlags.Object && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous) && type.symbol) {
177177
addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
178178
}
179179
addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature);

0 commit comments

Comments
 (0)