@@ -2164,7 +2164,7 @@ namespace ts {
2164
2164
? "any"
2165
2165
: (<IntrinsicType>type).intrinsicName);
2166
2166
}
2167
- else if (type.flags & TypeFlags.ThisType ) {
2167
+ else if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ) {
2168
2168
if (inObjectTypeLiteral) {
2169
2169
writer.reportInaccessibleThisError();
2170
2170
}
@@ -3155,9 +3155,9 @@ namespace ts {
3155
3155
}
3156
3156
3157
3157
// Return the type implied by an object binding pattern
3158
- function getTypeFromObjectBindingPattern(pattern: ObjectBindingPattern, includePatternInType: boolean, reportErrors: boolean): Type {
3158
+ function getTypeFromObjectBindingPattern(pattern: ObjectBindingPattern, includePatternInType: boolean, reportErrors: boolean): ResolvedType {
3159
3159
const members = createMap<Symbol>();
3160
- let hasComputedProperties = false ;
3160
+ let hasComputedProperties: boolean ;
3161
3161
forEach(pattern.elements, e => {
3162
3162
const name = e.propertyName || <Identifier>e.name;
3163
3163
if (isComputedNonLiteralName(name)) {
@@ -3177,9 +3177,7 @@ namespace ts {
3177
3177
if (includePatternInType) {
3178
3178
result.pattern = pattern;
3179
3179
}
3180
- if (hasComputedProperties) {
3181
- result.flags |= TypeFlags.ObjectLiteralPatternWithComputedProperties;
3182
- }
3180
+ result.inObjectLiteralPatternWithComputedProperties = hasComputedProperties;
3183
3181
return result;
3184
3182
}
3185
3183
@@ -3765,7 +3763,8 @@ namespace ts {
3765
3763
(<GenericType>type).instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
3766
3764
(<GenericType>type).target = <GenericType>type;
3767
3765
(<GenericType>type).typeArguments = type.typeParameters;
3768
- type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
3766
+ type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
3767
+ type.thisType.isThisType = true;
3769
3768
type.thisType.symbol = symbol;
3770
3769
type.thisType.constraint = type;
3771
3770
}
@@ -4414,7 +4413,7 @@ namespace ts {
4414
4413
* boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
4415
4414
* type itself. Note that the apparent type of a union type is the union type itself.
4416
4415
*/
4417
- function getApparentType(type: Type): Type {
4416
+ function getApparentType(type: Type): ObjectType {
4418
4417
if (type.flags & TypeFlags.TypeParameter) {
4419
4418
type = getApparentTypeOfTypeParameter(<TypeParameter>type);
4420
4419
}
@@ -4967,7 +4966,7 @@ namespace ts {
4967
4966
4968
4967
function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean {
4969
4968
let checked: Type[];
4970
- while (type && !( type.flags & TypeFlags.ThisType) && type.flags & TypeFlags. TypeParameter && !contains(checked, type)) {
4969
+ while (type && type.flags & TypeFlags.TypeParameter && !(( type as TypeParameter).isThisType) && !contains(checked, type)) {
4971
4970
if (type === target) {
4972
4971
return true;
4973
4972
}
@@ -5330,7 +5329,8 @@ namespace ts {
5330
5329
type.instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
5331
5330
type.target = <GenericType>type;
5332
5331
type.typeArguments = type.typeParameters;
5333
- type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
5332
+ type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
5333
+ type.thisType.isThisType = true;
5334
5334
type.thisType.constraint = type;
5335
5335
type.declaredProperties = properties;
5336
5336
type.declaredCallSignatures = emptyArray;
@@ -5920,7 +5920,8 @@ namespace ts {
5920
5920
mapper.instantiations = [];
5921
5921
}
5922
5922
// Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
5923
- const result = <AnonymousType>createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol);
5923
+ const result = <AnonymousType>createObjectType(TypeFlags.Anonymous, type.symbol);
5924
+ result.isInstantiated = true;
5924
5925
result.target = type;
5925
5926
result.mapper = mapper;
5926
5927
result.aliasSymbol = type.aliasSymbol;
@@ -5992,7 +5993,7 @@ namespace ts {
5992
5993
// instantiation.
5993
5994
return type.symbol &&
5994
5995
type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) &&
5995
- (type.flags & TypeFlags.Instantiated || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ?
5996
+ (( type as AnonymousType).isInstantiated || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ?
5996
5997
instantiateAnonymousType(<AnonymousType>type, mapper) : type;
5997
5998
}
5998
5999
if (type.flags & TypeFlags.Reference) {
@@ -6646,7 +6647,7 @@ namespace ts {
6646
6647
}
6647
6648
6648
6649
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
6649
- if (! (target.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties ) && maybeTypeOfKind (target, TypeFlags. ObjectType)) {
6650
+ if (maybeTypeOfKind (target, TypeFlags.ObjectType ) && ! (target as ObjectType).inObjectLiteralPatternWithComputedProperties ) {
6650
6651
for (const prop of getPropertiesOfObjectType(source)) {
6651
6652
if (!isKnownProperty(target, prop.name)) {
6652
6653
if (reportErrors) {
@@ -7140,12 +7141,12 @@ namespace ts {
7140
7141
// some level beyond that.
7141
7142
function isDeeplyNestedGeneric(type: Type, stack: Type[], depth: number): boolean {
7142
7143
// We track type references (created by createTypeReference) and instantiated types (created by instantiateType)
7143
- if (type.flags & ( TypeFlags.Reference | TypeFlags.Instantiated ) && depth >= 5) {
7144
+ if (( type.flags & TypeFlags.Reference || type.flags & TypeFlags.Anonymous && (type as AnonymousType).isInstantiated ) && depth >= 5) {
7144
7145
const symbol = type.symbol;
7145
7146
let count = 0;
7146
7147
for (let i = 0; i < depth; i++) {
7147
7148
const t = stack[i];
7148
- if (t.flags & ( TypeFlags.Reference | TypeFlags.Instantiated ) && t.symbol === symbol) {
7149
+ if (( t.flags & TypeFlags.Reference || t.flags & TypeFlags.Anonymous && (t as AnonymousType).isInstantiated ) && t.symbol === symbol) {
7149
7150
count++;
7150
7151
if (count >= 5) return true;
7151
7152
}
@@ -9937,7 +9938,7 @@ namespace ts {
9937
9938
9938
9939
// Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily
9939
9940
// be "pushed" onto a node using the contextualType property.
9940
- function getApparentTypeOfContextualType(node: Expression): Type {
9941
+ function getApparentTypeOfContextualType(node: Expression): ObjectType {
9941
9942
const type = getContextualType(node);
9942
9943
return type && getApparentType(type);
9943
9944
}
@@ -10271,7 +10272,7 @@ namespace ts {
10271
10272
const contextualTypeHasPattern = contextualType && contextualType.pattern &&
10272
10273
(contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression);
10273
10274
let typeFlags: TypeFlags = 0;
10274
- let patternWithComputedProperties = false ;
10275
+ let patternWithComputedProperties: boolean | undefined ;
10275
10276
let hasComputedStringProperty = false;
10276
10277
let hasComputedNumberProperty = false;
10277
10278
@@ -10306,7 +10307,7 @@ namespace ts {
10306
10307
patternWithComputedProperties = true;
10307
10308
}
10308
10309
}
10309
- else if (contextualTypeHasPattern && !( contextualType.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties) ) {
10310
+ else if (contextualTypeHasPattern && !contextualType.inObjectLiteralPatternWithComputedProperties ) {
10310
10311
// If object literal is contextually typed by the implied type of a binding pattern, and if the
10311
10312
// binding pattern specifies a default value for the property, make the property optional.
10312
10313
const impliedProp = getPropertyOfType(contextualType, member.name);
@@ -10371,7 +10372,8 @@ namespace ts {
10371
10372
const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.Number) : undefined;
10372
10373
const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
10373
10374
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral;
10374
- result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags) | (patternWithComputedProperties ? TypeFlags.ObjectLiteralPatternWithComputedProperties : 0);
10375
+ result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags);
10376
+ result.inObjectLiteralPatternWithComputedProperties = patternWithComputedProperties;
10375
10377
if (inDestructuringPattern) {
10376
10378
result.pattern = node;
10377
10379
}
@@ -10941,7 +10943,7 @@ namespace ts {
10941
10943
return true;
10942
10944
}
10943
10945
// An instance property must be accessed through an instance of the enclosing class
10944
- if (type.flags & TypeFlags.ThisType ) {
10946
+ if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ) {
10945
10947
// get the original type -- represented as the type constraint of the 'this' type
10946
10948
type = getConstraintOfTypeParameter(<TypeParameter>type);
10947
10949
}
@@ -10991,7 +10993,7 @@ namespace ts {
10991
10993
const prop = getPropertyOfType(apparentType, right.text);
10992
10994
if (!prop) {
10993
10995
if (right.text && !checkAndReportErrorForExtendingInterface(node)) {
10994
- reportNonexistentProperty(right, type.flags & TypeFlags.ThisType ? apparentType : type);
10996
+ reportNonexistentProperty(right, type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ? apparentType : type);
10995
10997
}
10996
10998
return unknownType;
10997
10999
}
0 commit comments