@@ -12302,7 +12302,7 @@ namespace ts {
12302
12302
let depth = 0;
12303
12303
let expandingFlags = ExpandingFlags.None;
12304
12304
let overflow = false;
12305
- let suppressNextError = false ;
12305
+ let overrideNextErrorInfo: DiagnosticMessageChain | undefined ;
12306
12306
12307
12307
Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
12308
12308
@@ -12589,10 +12589,14 @@ namespace ts {
12589
12589
}
12590
12590
12591
12591
if (!result && reportErrors) {
12592
- const maybeSuppress = suppressNextError ;
12593
- suppressNextError = false ;
12592
+ let maybeSuppress = overrideNextErrorInfo ;
12593
+ overrideNextErrorInfo = undefined ;
12594
12594
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) {
12595
+ const currentError = errorInfo;
12595
12596
tryElaborateArrayLikeErrors(source, target, reportErrors);
12597
+ if (errorInfo !== currentError) {
12598
+ maybeSuppress = errorInfo;
12599
+ }
12596
12600
}
12597
12601
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) {
12598
12602
tryElaborateErrorsForPrimitivesAndObjects(source, target);
@@ -13524,16 +13528,20 @@ namespace ts {
13524
13528
if (unmatchedProperty) {
13525
13529
if (reportErrors) {
13526
13530
const props = arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, /*matchDiscriminantProperties*/ false));
13531
+ let shouldSkipElaboration = false;
13527
13532
if (!headMessage || (headMessage.code !== Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
13528
13533
headMessage.code !== Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
13529
- suppressNextError = true; // Retain top-level error for interface implementing issues, otherwise omit it
13534
+ shouldSkipElaboration = true; // Retain top-level error for interface implementing issues, otherwise omit it
13530
13535
}
13531
13536
if (props.length === 1) {
13532
13537
const propName = symbolToString(unmatchedProperty);
13533
13538
reportError(Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, ...getTypeNamesForErrorDisplay(source, target));
13534
13539
if (length(unmatchedProperty.declarations)) {
13535
13540
associateRelatedInfo(createDiagnosticForNode(unmatchedProperty.declarations[0], Diagnostics._0_is_declared_here, propName));
13536
13541
}
13542
+ if (shouldSkipElaboration) {
13543
+ overrideNextErrorInfo = errorInfo;
13544
+ }
13537
13545
}
13538
13546
else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) {
13539
13547
if (props.length > 5) { // arbitrary cutoff for too-long list form
@@ -13542,7 +13550,11 @@ namespace ts {
13542
13550
else {
13543
13551
reportError(Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), map(props, p => symbolToString(p)).join(", "));
13544
13552
}
13553
+ if (shouldSkipElaboration) {
13554
+ overrideNextErrorInfo = errorInfo;
13555
+ }
13545
13556
}
13557
+ // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined)
13546
13558
}
13547
13559
return Ternary.False;
13548
13560
}
0 commit comments