@@ -3563,7 +3563,7 @@ namespace ts {
3563
3563
context.approximateLength += 6;
3564
3564
return createKeywordTypeNode(SyntaxKind.ObjectKeyword);
3565
3565
}
3566
- if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ) {
3566
+ if (isThisTypeParameter (type) ) {
3567
3567
if (context.flags & NodeBuilderFlags.InObjectTypeLiteral) {
3568
3568
if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowThisInObjectLiteral)) {
3569
3569
context.encounteredError = true;
@@ -10193,6 +10193,10 @@ namespace ts {
10193
10193
return maybeTypeOfKind(type, TypeFlags.InstantiableNonPrimitive | TypeFlags.Index);
10194
10194
}
10195
10195
10196
+ function isThisTypeParameter(type: Type): boolean {
10197
+ return !!(type.flags & TypeFlags.TypeParameter && (<TypeParameter>type).isThisType);
10198
+ }
10199
+
10196
10200
function getSimplifiedType(type: Type, writing: boolean): Type {
10197
10201
return type.flags & TypeFlags.IndexedAccess ? getSimplifiedIndexedAccessType(<IndexedAccessType>type, writing) :
10198
10202
type.flags & TypeFlags.Conditional ? getSimplifiedConditionalType(<ConditionalType>type, writing) :
@@ -16772,7 +16776,7 @@ namespace ts {
16772
16776
}
16773
16777
16774
16778
function narrowByInKeyword(type: Type, literal: LiteralExpression, assumeTrue: boolean) {
16775
- if (( type.flags & (TypeFlags.Union | TypeFlags.Object)) || (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType )) {
16779
+ if (type.flags & (TypeFlags.Union | TypeFlags.Object) || isThisTypeParameter (type)) {
16776
16780
const propName = escapeLeadingUnderscores(literal.text);
16777
16781
return filterType(type, t => isTypePresencePossible(t, propName, assumeTrue));
16778
16782
}
@@ -20092,7 +20096,7 @@ namespace ts {
20092
20096
return anyType;
20093
20097
}
20094
20098
if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
20095
- reportNonexistentProperty(right, leftType.flags & TypeFlags.TypeParameter && (leftType as TypeParameter).isThisType ? apparentType : leftType);
20099
+ reportNonexistentProperty(right, isThisTypeParameter (leftType) ? apparentType : leftType);
20096
20100
}
20097
20101
return errorType;
20098
20102
}
@@ -20496,7 +20500,7 @@ namespace ts {
20496
20500
20497
20501
const effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
20498
20502
const accessFlags = isAssignmentTarget(node) ?
20499
- AccessFlags.Writing | (isGenericObjectType(objectType) ? AccessFlags.NoIndexSignatures : 0) :
20503
+ AccessFlags.Writing | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? AccessFlags.NoIndexSignatures : 0) :
20500
20504
AccessFlags.None;
20501
20505
const indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
20502
20506
return checkIndexedAccessIndexType(indexedAccessType, node);
0 commit comments