@@ -2165,7 +2165,7 @@ namespace ts {
21652165 ? "any"
21662166 : (<IntrinsicType>type).intrinsicName);
21672167 }
2168- else if (type.flags & TypeFlags.ThisType ) {
2168+ else if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ) {
21692169 if (inObjectTypeLiteral) {
21702170 writer.reportInaccessibleThisError();
21712171 }
@@ -3179,7 +3179,7 @@ namespace ts {
31793179 result.pattern = pattern;
31803180 }
31813181 if (hasComputedProperties) {
3182- result.flags |= TypeFlags.ObjectLiteralPatternWithComputedProperties ;
3182+ result.isObjectLiteralPatternWithComputedProperties = true ;
31833183 }
31843184 return result;
31853185 }
@@ -3766,7 +3766,8 @@ namespace ts {
37663766 (<GenericType>type).instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
37673767 (<GenericType>type).target = <GenericType>type;
37683768 (<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;
37703771 type.thisType.symbol = symbol;
37713772 type.thisType.constraint = type;
37723773 }
@@ -4968,7 +4969,7 @@ namespace ts {
49684969
49694970 function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean {
49704971 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)) {
49724973 if (type === target) {
49734974 return true;
49744975 }
@@ -5331,7 +5332,8 @@ namespace ts {
53315332 type.instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
53325333 type.target = <GenericType>type;
53335334 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;
53355337 type.thisType.constraint = type;
53365338 type.declaredProperties = properties;
53375339 type.declaredCallSignatures = emptyArray;
@@ -6647,7 +6649,8 @@ namespace ts {
66476649 }
66486650
66496651 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)) {
66516654 for (const prop of getPropertiesOfObjectType(source)) {
66526655 if (!isKnownProperty(target, prop.name)) {
66536656 if (reportErrors) {
@@ -10307,7 +10310,8 @@ namespace ts {
1030710310 patternWithComputedProperties = true;
1030810311 }
1030910312 }
10310- else if (contextualTypeHasPattern && !(contextualType.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties)) {
10313+ else if (contextualTypeHasPattern &&
10314+ !(contextualType.flags & TypeFlags.ObjectType && (contextualType as ObjectType).isObjectLiteralPatternWithComputedProperties)) {
1031110315 // If object literal is contextually typed by the implied type of a binding pattern, and if the
1031210316 // binding pattern specifies a default value for the property, make the property optional.
1031310317 const impliedProp = getPropertyOfType(contextualType, member.name);
@@ -10372,7 +10376,10 @@ namespace ts {
1037210376 const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.Number) : undefined;
1037310377 const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
1037410378 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+ }
1037610383 if (inDestructuringPattern) {
1037710384 result.pattern = node;
1037810385 }
@@ -10942,7 +10949,7 @@ namespace ts {
1094210949 return true;
1094310950 }
1094410951 // 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 ) {
1094610953 // get the original type -- represented as the type constraint of the 'this' type
1094710954 type = getConstraintOfTypeParameter(<TypeParameter>type);
1094810955 }
@@ -10992,7 +10999,7 @@ namespace ts {
1099210999 const prop = getPropertyOfType(apparentType, right.text);
1099311000 if (!prop) {
1099411001 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);
1099611003 }
1099711004 return unknownType;
1099811005 }
0 commit comments