diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 46cb8bb4937..5b1d4d77bf7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14599,9 +14599,13 @@ namespace ts { } const prop = getPropertyOfType(apparentType, right.escapedText); if (!prop) { - const stringIndexType = getIndexTypeOfType(apparentType, IndexKind.String); - if (stringIndexType) { - return stringIndexType; + const indexInfo = getIndexInfoOfType(apparentType, IndexKind.String); + if (indexInfo && indexInfo.type) { + if (indexInfo.isReadonly && (isAssignmentTarget(node) || isDeleteTarget(node))) { + error(node, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); + return unknownType; + } + return indexInfo.type; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ? apparentType : type);