@@ -12290,7 +12290,7 @@ namespace ts {
1229012290 let depth = 0;
1229112291 let expandingFlags = ExpandingFlags.None;
1229212292 let overflow = false;
12293- let suppressNextError = false ;
12293+ let overrideNextErrorInfo: DiagnosticMessageChain | undefined ;
1229412294
1229512295 Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
1229612296
@@ -12571,10 +12571,14 @@ namespace ts {
1257112571 }
1257212572
1257312573 if (!result && reportErrors) {
12574- const maybeSuppress = suppressNextError ;
12575- suppressNextError = false ;
12574+ let maybeSuppress = overrideNextErrorInfo ;
12575+ overrideNextErrorInfo = undefined ;
1257612576 if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) {
12577+ const currentError = errorInfo;
1257712578 tryElaborateArrayLikeErrors(source, target, reportErrors);
12579+ if (errorInfo !== currentError) {
12580+ maybeSuppress = errorInfo;
12581+ }
1257812582 }
1257912583 if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) {
1258012584 tryElaborateErrorsForPrimitivesAndObjects(source, target);
@@ -13506,16 +13510,20 @@ namespace ts {
1350613510 if (unmatchedProperty) {
1350713511 if (reportErrors) {
1350813512 const props = arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, /*matchDiscriminantProperties*/ false));
13513+ let shouldSkipElaboration = false;
1350913514 if (!headMessage || (headMessage.code !== Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
1351013515 headMessage.code !== Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
13511- suppressNextError = true; // Retain top-level error for interface implementing issues, otherwise omit it
13516+ shouldSkipElaboration = true; // Retain top-level error for interface implementing issues, otherwise omit it
1351213517 }
1351313518 if (props.length === 1) {
1351413519 const propName = symbolToString(unmatchedProperty);
1351513520 reportError(Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, ...getTypeNamesForErrorDisplay(source, target));
1351613521 if (length(unmatchedProperty.declarations)) {
1351713522 associateRelatedInfo(createDiagnosticForNode(unmatchedProperty.declarations[0], Diagnostics._0_is_declared_here, propName));
1351813523 }
13524+ if (shouldSkipElaboration) {
13525+ overrideNextErrorInfo = errorInfo;
13526+ }
1351913527 }
1352013528 else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) {
1352113529 if (props.length > 5) { // arbitrary cutoff for too-long list form
@@ -13524,7 +13532,11 @@ namespace ts {
1352413532 else {
1352513533 reportError(Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), map(props, p => symbolToString(p)).join(", "));
1352613534 }
13535+ if (shouldSkipElaboration) {
13536+ overrideNextErrorInfo = errorInfo;
13537+ }
1352713538 }
13539+ // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined)
1352813540 }
1352913541 return Ternary.False;
1353013542 }
0 commit comments