Non-fresh {} is not a subtype of { [x: string]: xxx }

This commit is contained in:
Anders Hejlsberg
2022-07-22 16:38:26 -07:00
parent 7b764164ed
commit 823b220219

View File

@@ -20621,7 +20621,8 @@ namespace ts {
if (sourceInfo) {
return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors);
}
if (!(intersectionState & IntersectionState.Source) && isObjectTypeWithInferableIndex(source)) {
if (!(intersectionState & IntersectionState.Source) && isObjectTypeWithInferableIndex(source) &&
!((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyAnonymousObjectType(source) && !(getObjectFlags(source) & ObjectFlags.FreshLiteral))) {
// Intersection constituents are never considered to have an inferred index signature
return membersRelatedToIndexInfo(source, targetInfo, reportErrors);
}