Exclude special index signature rule from strict subtype relation (#53388)

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
Anders Hejlsberg
2023-03-23 07:03:09 -07:00
committed by GitHub
parent 7009c76d00
commit 25550bd3d6
6 changed files with 744 additions and 72 deletions

View File

@@ -22485,7 +22485,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const targetHasStringIndex = some(indexInfos, info => info.keyType === stringType);
let result = Ternary.True;
for (const targetInfo of indexInfos) {
const related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & TypeFlags.Any ? Ternary.True :
const related = relation !== strictSubtypeRelation && !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & TypeFlags.Any ? Ternary.True :
isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, RecursionFlags.Both, reportErrors) :
typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
if (!related) {