Skip to content

Commit e224083

Browse files
Updated error message.
1 parent ab7c4e5 commit e224083

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

src/compiler/checker.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4832,7 +4832,14 @@ namespace ts {
48324832
sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType);
48334833
targetType = typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType);
48344834
}
4835-
reportError(message || Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType);
4835+
4836+
if (!message) {
4837+
message = relation === comparableRelation ?
4838+
Diagnostics.Type_0_is_not_comparable_with_type_1 :
4839+
Diagnostics.Type_0_is_not_assignable_to_type_1
4840+
}
4841+
4842+
reportError(message, sourceType, targetType);
48364843
}
48374844

48384845
// Compare two types and return
@@ -9411,7 +9418,7 @@ namespace ts {
94119418
let widenedType = getWidenedType(exprType);
94129419

94139420
if (!isTypeComparableTo(targetType, widenedType)) {
9414-
checkTypeComparableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
9421+
checkTypeComparableTo(exprType, targetType, node);
94159422
}
94169423
}
94179424
return targetType;

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,10 @@
888888
"category": "Error",
889889
"code": 2322
890890
},
891+
"Type '{0}' is not comparable with type '{1}'.": {
892+
"category": "Error",
893+
"code": 2323
894+
},
891895
"Property '{0}' is missing in type '{1}'.": {
892896
"category": "Error",
893897
"code": 2324
@@ -996,10 +1000,6 @@
9961000
"category": "Error",
9971001
"code": 2351
9981002
},
999-
"Neither type '{0}' nor type '{1}' is assignable to the other.": {
1000-
"category": "Error",
1001-
"code": 2352
1002-
},
10031003
"Object literal may only specify known properties, and '{0}' does not exist in type '{1}'.": {
10041004
"category": "Error",
10051005
"code": 2353

0 commit comments

Comments
 (0)