@@ -21329,11 +21329,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21329
21329
return Ternary.False;
21330
21330
}
21331
21331
}
21332
- // A fresh empty object type is never a subtype of a non-empty object type and an empty object type is never a subtype of
21333
- // a non-empty object type. This ensures fresh({}) <: { [x: string]: xxx } and { [x: string: xxx] } <: {}. Without these
21334
- // rules, those types would be mutual subtypes.
21335
- else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && getObjectFlags(target) & ObjectFlags.FreshLiteral && !isEmptyObjectType(source) ||
21336
- (relation === strictSubtypeRelation && target.flags & TypeFlags.Object && !isEmptyObjectType(target) && isEmptyObjectType(source) && !(getObjectFlags(source) & ObjectFlags.FreshLiteral))) {
21332
+ // A fresh empty object type is never a subtype of a non-empty object type. This ensures fresh({}) <: { [x: string]: xxx }
21333
+ // but not vice-versa. Without this rule, those types would be mutual subtypes.
21334
+ else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && getObjectFlags(target) & ObjectFlags.FreshLiteral && !isEmptyObjectType(source)) {
21337
21335
return Ternary.False;
21338
21336
}
21339
21337
// Even if relationship doesn't hold for unions, intersections, or generic type references,
@@ -22084,8 +22082,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
22084
22082
if (sourceInfo) {
22085
22083
return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors);
22086
22084
}
22087
- if (!(intersectionState & IntersectionState.Source) && isObjectTypeWithInferableIndex(source)) {
22088
- // Intersection constituents are never considered to have an inferred index signature
22085
+ // Intersection constituents are never considered to have an inferred index signature. Also, in the strict subtype relation,
22086
+ // only fresh object literals are considered to have inferred index signatures. This ensures { [x: string]: xxx } <: {} but
22087
+ // not vice-versa. Without this rule, those types would be mutual strict subtypes.
22088
+ if (!(intersectionState & IntersectionState.Source) && (relation !== strictSubtypeRelation || getObjectFlags(source) & ObjectFlags.FreshLiteral) && isObjectTypeWithInferableIndex(source)) {
22089
22089
return membersRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
22090
22090
}
22091
22091
if (reportErrors) {
0 commit comments