From e224083038b15ecd20990bd4e4fb223c1928bc9e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 3 Nov 2015 17:17:53 -0800 Subject: [PATCH] Updated error message. --- src/compiler/checker.ts | 11 +++++++++-- src/compiler/diagnosticMessages.json | 8 ++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac44a748d6c..a804cacb7de 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4832,7 +4832,14 @@ namespace ts { sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType); targetType = typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType); } - reportError(message || Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType); + + if (!message) { + message = relation === comparableRelation ? + Diagnostics.Type_0_is_not_comparable_with_type_1 : + Diagnostics.Type_0_is_not_assignable_to_type_1 + } + + reportError(message, sourceType, targetType); } // Compare two types and return @@ -9411,7 +9418,7 @@ namespace ts { let widenedType = getWidenedType(exprType); if (!isTypeComparableTo(targetType, widenedType)) { - checkTypeComparableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); + checkTypeComparableTo(exprType, targetType, node); } } return targetType; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4fdeb122983..4f1b4869918 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -888,6 +888,10 @@ "category": "Error", "code": 2322 }, + "Type '{0}' is not comparable with type '{1}'.": { + "category": "Error", + "code": 2323 + }, "Property '{0}' is missing in type '{1}'.": { "category": "Error", "code": 2324 @@ -996,10 +1000,6 @@ "category": "Error", "code": 2351 }, - "Neither type '{0}' nor type '{1}' is assignable to the other.": { - "category": "Error", - "code": 2352 - }, "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'.": { "category": "Error", "code": 2353