Eased up on some of the more aggressive reporting changes

This commit is contained in:
Josh Goldberg
2020-04-19 20:25:24 -04:00
parent af4ea605f2
commit 769a2f2cfc
16 changed files with 57 additions and 55 deletions

View File

@@ -4073,9 +4073,6 @@ namespace ts {
leftStr = getTypeNameForErrorDisplay(left);
rightStr = getTypeNameForErrorDisplay(right);
}
else if (isLiteralType(left) && !isLiteralType(right)) {
leftStr = getTypeNameForErrorDisplay(getBaseTypeOfLiteralType(left))
}
return [leftStr, rightStr];
}
@@ -15458,6 +15455,7 @@ namespace ts {
function reportRelationError(message: DiagnosticMessage | undefined, source: Type, target: Type) {
if (incompatibleStack.length) reportIncompatibleStack();
const [sourceType, targetType] = getTypeNamesForErrorDisplay(source, target);
let generalizedSourceType = sourceType;
if (target.flags & TypeFlags.TypeParameter) {
const constraint = getBaseConstraintOfType(target);
@@ -15491,7 +15489,11 @@ namespace ts {
}
}
reportError(message, sourceType, targetType);
if (isLiteralType(source) && !isLiteralType(target)) {
generalizedSourceType = getTypeNameForErrorDisplay(getBaseTypeOfLiteralType(source))
}
reportError(message, generalizedSourceType, targetType);
}
function tryElaborateErrorsForPrimitivesAndObjects(source: Type, target: Type) {

View File

@@ -175,7 +175,7 @@ bar();`
file,
syntax: [],
semantic: [
createDiagnostic(locationOfY.start, locationOfY.end, Diagnostics.Type_0_is_not_assignable_to_type_1, ["number", "string"]),
createDiagnostic(locationOfY.start, locationOfY.end, Diagnostics.Type_0_is_not_assignable_to_type_1, ["10", "string"]),
],
suggestion: []
},

View File

@@ -166,7 +166,7 @@ fnErr();
{ line: 6, offset: 12 },
{ line: 6, offset: 13 },
Diagnostics.Type_0_is_not_assignable_to_type_1,
["number", "string"],
["10", "string"],
"error",
)
],
@@ -235,7 +235,7 @@ fnErr();
{ line: 6, offset: 5 },
{ line: 6, offset: 6 },
Diagnostics.Type_0_is_not_assignable_to_type_1,
["number", "string"],
["10", "string"],
"error",
)
],