@@ -12290,7 +12290,7 @@ namespace ts {
12290
12290
let depth = 0;
12291
12291
let expandingFlags = ExpandingFlags.None;
12292
12292
let overflow = false;
12293
- let suppressNextError = false ;
12293
+ let overrideNextErrorInfo: DiagnosticMessageChain | undefined ;
12294
12294
12295
12295
Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
12296
12296
@@ -12571,10 +12571,14 @@ namespace ts {
12571
12571
}
12572
12572
12573
12573
if (!result && reportErrors) {
12574
- const maybeSuppress = suppressNextError ;
12575
- suppressNextError = false ;
12574
+ let maybeSuppress = overrideNextErrorInfo ;
12575
+ overrideNextErrorInfo = undefined ;
12576
12576
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) {
12577
+ const currentError = errorInfo;
12577
12578
tryElaborateArrayLikeErrors(source, target, reportErrors);
12579
+ if (errorInfo !== currentError) {
12580
+ maybeSuppress = errorInfo;
12581
+ }
12578
12582
}
12579
12583
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) {
12580
12584
tryElaborateErrorsForPrimitivesAndObjects(source, target);
@@ -13506,16 +13510,20 @@ namespace ts {
13506
13510
if (unmatchedProperty) {
13507
13511
if (reportErrors) {
13508
13512
const props = arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, /*matchDiscriminantProperties*/ false));
13513
+ let shouldSkipElaboration = false;
13509
13514
if (!headMessage || (headMessage.code !== Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
13510
13515
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
13512
13517
}
13513
13518
if (props.length === 1) {
13514
13519
const propName = symbolToString(unmatchedProperty);
13515
13520
reportError(Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, ...getTypeNamesForErrorDisplay(source, target));
13516
13521
if (length(unmatchedProperty.declarations)) {
13517
13522
associateRelatedInfo(createDiagnosticForNode(unmatchedProperty.declarations[0], Diagnostics._0_is_declared_here, propName));
13518
13523
}
13524
+ if (shouldSkipElaboration) {
13525
+ overrideNextErrorInfo = errorInfo;
13526
+ }
13519
13527
}
13520
13528
else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) {
13521
13529
if (props.length > 5) { // arbitrary cutoff for too-long list form
@@ -13524,7 +13532,11 @@ namespace ts {
13524
13532
else {
13525
13533
reportError(Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), map(props, p => symbolToString(p)).join(", "));
13526
13534
}
13535
+ if (shouldSkipElaboration) {
13536
+ overrideNextErrorInfo = errorInfo;
13537
+ }
13527
13538
}
13539
+ // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined)
13528
13540
}
13529
13541
return Ternary.False;
13530
13542
}
0 commit comments