Fix error message regressed by #30916 (#31276)

This commit is contained in:
Wesley Wigham
2019-05-14 16:58:06 -07:00
committed by GitHub
parent fb6ae38ddf
commit 3885e3fcda
6 changed files with 48 additions and 4 deletions

View File

@@ -12290,7 +12290,7 @@ namespace ts {
let depth = 0;
let expandingFlags = ExpandingFlags.None;
let overflow = false;
let suppressNextError = false;
let overrideNextErrorInfo: DiagnosticMessageChain | undefined;
Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
@@ -12571,10 +12571,14 @@ namespace ts {
}
if (!result && reportErrors) {
const maybeSuppress = suppressNextError;
suppressNextError = false;
let maybeSuppress = overrideNextErrorInfo;
overrideNextErrorInfo = undefined;
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) {
const currentError = errorInfo;
tryElaborateArrayLikeErrors(source, target, reportErrors);
if (errorInfo !== currentError) {
maybeSuppress = errorInfo;
}
}
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) {
tryElaborateErrorsForPrimitivesAndObjects(source, target);
@@ -13506,9 +13510,10 @@ namespace ts {
if (unmatchedProperty) {
if (reportErrors) {
const props = arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, /*matchDiscriminantProperties*/ false));
let shouldSkipElaboration = false;
if (!headMessage || (headMessage.code !== Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
headMessage.code !== Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
suppressNextError = true; // Retain top-level error for interface implementing issues, otherwise omit it
shouldSkipElaboration = true; // Retain top-level error for interface implementing issues, otherwise omit it
}
if (props.length === 1) {
const propName = symbolToString(unmatchedProperty);
@@ -13516,6 +13521,9 @@ namespace ts {
if (length(unmatchedProperty.declarations)) {
associateRelatedInfo(createDiagnosticForNode(unmatchedProperty.declarations[0], Diagnostics._0_is_declared_here, propName));
}
if (shouldSkipElaboration) {
overrideNextErrorInfo = errorInfo;
}
}
else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) {
if (props.length > 5) { // arbitrary cutoff for too-long list form
@@ -13524,7 +13532,11 @@ namespace ts {
else {
reportError(Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), map(props, p => symbolToString(p)).join(", "));
}
if (shouldSkipElaboration) {
overrideNextErrorInfo = errorInfo;
}
}
// ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined)
}
return Ternary.False;
}