@@ -2165,7 +2165,7 @@ namespace ts {
2165
2165
? "any"
2166
2166
: (<IntrinsicType>type).intrinsicName);
2167
2167
}
2168
- else if (type.flags & TypeFlags.ThisType ) {
2168
+ else if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ) {
2169
2169
if (inObjectTypeLiteral) {
2170
2170
writer.reportInaccessibleThisError();
2171
2171
}
@@ -3179,7 +3179,7 @@ namespace ts {
3179
3179
result.pattern = pattern;
3180
3180
}
3181
3181
if (hasComputedProperties) {
3182
- result.flags |= TypeFlags.ObjectLiteralPatternWithComputedProperties ;
3182
+ result.isObjectLiteralPatternWithComputedProperties = true ;
3183
3183
}
3184
3184
return result;
3185
3185
}
@@ -3766,7 +3766,8 @@ namespace ts {
3766
3766
(<GenericType>type).instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
3767
3767
(<GenericType>type).target = <GenericType>type;
3768
3768
(<GenericType>type).typeArguments = type.typeParameters;
3769
- type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
3769
+ type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
3770
+ type.thisType.isThisType = true;
3770
3771
type.thisType.symbol = symbol;
3771
3772
type.thisType.constraint = type;
3772
3773
}
@@ -4968,7 +4969,7 @@ namespace ts {
4968
4969
4969
4970
function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean {
4970
4971
let checked: Type[];
4971
- while (type && !( type.flags & TypeFlags.ThisType) && type.flags & TypeFlags. TypeParameter && !contains(checked, type)) {
4972
+ while (type && type.flags & TypeFlags.TypeParameter && !(( type as TypeParameter).isThisType) && !contains(checked, type)) {
4972
4973
if (type === target) {
4973
4974
return true;
4974
4975
}
@@ -5331,7 +5332,8 @@ namespace ts {
5331
5332
type.instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
5332
5333
type.target = <GenericType>type;
5333
5334
type.typeArguments = type.typeParameters;
5334
- type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
5335
+ type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
5336
+ type.thisType.isThisType = true;
5335
5337
type.thisType.constraint = type;
5336
5338
type.declaredProperties = properties;
5337
5339
type.declaredCallSignatures = emptyArray;
@@ -6647,7 +6649,8 @@ namespace ts {
6647
6649
}
6648
6650
6649
6651
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
6650
- if (!(target.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties) && maybeTypeOfKind(target, TypeFlags.ObjectType)) {
6652
+ if (maybeTypeOfKind(target, TypeFlags.ObjectType) &&
6653
+ (!(target.flags & TypeFlags.ObjectType) || !(target as ObjectType).isObjectLiteralPatternWithComputedProperties)) {
6651
6654
for (const prop of getPropertiesOfObjectType(source)) {
6652
6655
if (!isKnownProperty(target, prop.name)) {
6653
6656
if (reportErrors) {
@@ -10307,7 +10310,8 @@ namespace ts {
10307
10310
patternWithComputedProperties = true;
10308
10311
}
10309
10312
}
10310
- else if (contextualTypeHasPattern && !(contextualType.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties)) {
10313
+ else if (contextualTypeHasPattern &&
10314
+ !(contextualType.flags & TypeFlags.ObjectType && (contextualType as ObjectType).isObjectLiteralPatternWithComputedProperties)) {
10311
10315
// If object literal is contextually typed by the implied type of a binding pattern, and if the
10312
10316
// binding pattern specifies a default value for the property, make the property optional.
10313
10317
const impliedProp = getPropertyOfType(contextualType, member.name);
@@ -10372,7 +10376,10 @@ namespace ts {
10372
10376
const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.Number) : undefined;
10373
10377
const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
10374
10378
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral;
10375
- result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags) | (patternWithComputedProperties ? TypeFlags.ObjectLiteralPatternWithComputedProperties : 0);
10379
+ result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags);
10380
+ if (patternWithComputedProperties) {
10381
+ result.isObjectLiteralPatternWithComputedProperties = true;
10382
+ }
10376
10383
if (inDestructuringPattern) {
10377
10384
result.pattern = node;
10378
10385
}
@@ -10942,7 +10949,7 @@ namespace ts {
10942
10949
return true;
10943
10950
}
10944
10951
// An instance property must be accessed through an instance of the enclosing class
10945
- if (type.flags & TypeFlags.ThisType ) {
10952
+ if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ) {
10946
10953
// get the original type -- represented as the type constraint of the 'this' type
10947
10954
type = getConstraintOfTypeParameter(<TypeParameter>type);
10948
10955
}
@@ -10992,7 +10999,7 @@ namespace ts {
10992
10999
const prop = getPropertyOfType(apparentType, right.text);
10993
11000
if (!prop) {
10994
11001
if (right.text && !checkAndReportErrorForExtendingInterface(node)) {
10995
- reportNonexistentProperty(right, type.flags & TypeFlags.ThisType ? apparentType : type);
11002
+ reportNonexistentProperty(right, type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ? apparentType : type);
10996
11003
}
10997
11004
return unknownType;
10998
11005
}
0 commit comments