Skip to content

Commit 9e1b530

Browse files
committed
Put TypeFlags.ObjectLiteral back
1 parent 561168c commit 9e1b530

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

src/compiler/checker.ts

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,16 @@ namespace ts {
134134
const neverType = createIntrinsicType(TypeFlags.Never, "never");
135135
const silentNeverType = createIntrinsicType(TypeFlags.Never, "never");
136136

137-
const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined, undefined);
138-
const emptyGenericType = <GenericType><ObjectType>createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined, undefined);
137+
const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
138+
const emptyGenericType = <GenericType><ObjectType>createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
139139
emptyGenericType.instantiations = createMap<TypeReference>();
140140

141-
const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined, undefined);
141+
const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
142142
// The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
143143
// in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes.
144144
anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType;
145145

146-
const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined, undefined);
146+
const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
147147

148148
const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
149149
const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
@@ -1618,12 +1618,9 @@ namespace ts {
16181618
return <ResolvedType>type;
16191619
}
16201620

1621-
function createAnonymousType(symbol: Symbol, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo, numberIndexInfo: IndexInfo, isObjectLiteral: boolean): ResolvedType {
1622-
const t = createObjectType(TypeFlags.Anonymous, symbol);
1623-
if (isObjectLiteral) {
1624-
t.isObjectLiteral = true;
1625-
}
1626-
return setObjectTypeMembers(t, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
1621+
function createAnonymousType(symbol: Symbol, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo, numberIndexInfo: IndexInfo): ResolvedType {
1622+
return setObjectTypeMembers(createObjectType(TypeFlags.Anonymous, symbol),
1623+
members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
16271624
}
16281625

16291626
function forEachSymbolTableInScope<T>(enclosingDeclaration: Node, callback: (symbolTable: SymbolTable) => T): T {
@@ -3176,7 +3173,7 @@ namespace ts {
31763173
symbol.bindingElement = e;
31773174
members[symbol.name] = symbol;
31783175
});
3179-
const result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined, undefined);
3176+
const result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
31803177
if (includePatternInType) {
31813178
result.pattern = pattern;
31823179
}
@@ -6477,7 +6474,7 @@ namespace ts {
64776474

64786475
if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True;
64796476

6480-
if (source.flags & TypeFlags.ObjectType && (source as ObjectType).isObjectLiteral && source.flags & TypeFlags.FreshLiteral) {
6477+
if (source.flags & TypeFlags.ObjectLiteral && source.flags & TypeFlags.FreshLiteral) {
64816478
if (hasExcessProperties(<FreshObjectLiteralType>source, target, reportErrors)) {
64826479
if (reportErrors) {
64836480
reportRelationError(headMessage, source, target);
@@ -6846,7 +6843,7 @@ namespace ts {
68466843
}
68476844
let result = Ternary.True;
68486845
const properties = getPropertiesOfObjectType(target);
6849-
const requireOptionalProperties = relation === subtypeRelation && !(source.flags & TypeFlags.ObjectType && (source as ObjectType).isObjectLiteral);
6846+
const requireOptionalProperties = relation === subtypeRelation && !(source.flags & TypeFlags.ObjectLiteral);
68506847
for (const targetProp of properties) {
68516848
const sourceProp = getPropertyOfType(source, targetProp.name);
68526849

@@ -7485,7 +7482,7 @@ namespace ts {
74857482
* Leave signatures alone since they are not subject to the check.
74867483
*/
74877484
function getRegularTypeOfObjectLiteral(type: Type): Type {
7488-
if (!(type.flags & TypeFlags.ObjectType && (type as ObjectType).isObjectLiteral && type.flags & TypeFlags.FreshLiteral)) {
7485+
if (!(type.flags & TypeFlags.ObjectLiteral && type.flags & TypeFlags.FreshLiteral)) {
74897486
return type;
74907487
}
74917488
const regularType = (<FreshObjectLiteralType>type).regularType;
@@ -7500,8 +7497,7 @@ namespace ts {
75007497
resolved.callSignatures,
75017498
resolved.constructSignatures,
75027499
resolved.stringIndexInfo,
7503-
resolved.numberIndexInfo,
7504-
resolved.isObjectLiteral);
7500+
resolved.numberIndexInfo);
75057501
regularNew.flags = resolved.flags & ~TypeFlags.FreshLiteral;
75067502
(<FreshObjectLiteralType>type).regularType = regularNew;
75077503
return regularNew;
@@ -7516,8 +7512,7 @@ namespace ts {
75167512
const numberIndexInfo = getIndexInfoOfType(type, IndexKind.Number);
75177513
return createAnonymousType(type.symbol, members, emptyArray, emptyArray,
75187514
stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly),
7519-
numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly),
7520-
(type as ObjectType).isObjectLiteral);
7515+
numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly));
75217516
}
75227517

75237518
function getWidenedConstituentType(type: Type): Type {
@@ -7529,8 +7524,7 @@ namespace ts {
75297524
if (type.flags & TypeFlags.Nullable) {
75307525
return anyType;
75317526
}
7532-
// if (type.flags & TypeFlags.ObjectLiteral) {
7533-
if (type.flags & TypeFlags.ObjectType && (type as ObjectType).isObjectLiteral) {
7527+
if (type.flags & TypeFlags.ObjectLiteral) {
75347528
return getWidenedTypeOfObjectLiteral(type);
75357529
}
75367530
if (type.flags & TypeFlags.Union) {
@@ -7570,7 +7564,7 @@ namespace ts {
75707564
}
75717565
}
75727566
}
7573-
if (type.flags & TypeFlags.ObjectType && (type as ObjectType).isObjectLiteral) {
7567+
if (type.flags & TypeFlags.ObjectLiteral) {
75747568
for (const p of getPropertiesOfObjectType(type)) {
75757569
const t = getTypeOfSymbol(p);
75767570
if (t.flags & TypeFlags.ContainsWideningType) {
@@ -10379,7 +10373,7 @@ namespace ts {
1037910373

1038010374
const stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.String) : undefined;
1038110375
const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.Number) : undefined;
10382-
const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo, /*isObjectLiteral*/ true);
10376+
const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
1038310377
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral;
1038410378
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags);
1038510379
if (patternWithComputedProperties) {
@@ -12492,7 +12486,7 @@ namespace ts {
1249212486
function getInferredClassType(symbol: Symbol) {
1249312487
const links = getSymbolLinks(symbol);
1249412488
if (!links.inferredClassType) {
12495-
links.inferredClassType = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined, /*isObjectLiteral*/ undefined);
12489+
links.inferredClassType = createAnonymousType(symbol, symbol.members, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined);
1249612490
}
1249712491
return links.inferredClassType;
1249812492
}

src/compiler/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,6 @@ namespace ts {
24622462

24632463
// Object types (TypeFlags.ObjectType)
24642464
export interface ObjectType extends Type {
2465-
isObjectLiteral?: boolean;
24662465
inObjectLiteralPatternWithComputedProperties?: boolean;
24672466
}
24682467

0 commit comments

Comments
 (0)