Skip to content

Commit 2f34f7c

Browse files
committed
Improve more error messages
1 parent 88961cd commit 2f34f7c

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13614,7 +13614,7 @@ namespace ts {
1361413614
if (ok) {
1361513615
// run check only if former checks succeeded to avoid reporting cascading errors
1361613616
checkReferenceExpression(node.operand,
13617-
Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer,
13617+
Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access,
1361813618
Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property);
1361913619
}
1362013620
return numberType;
@@ -13632,7 +13632,7 @@ namespace ts {
1363213632
if (ok) {
1363313633
// run check only if former checks succeeded to avoid reporting cascading errors
1363413634
checkReferenceExpression(node.operand,
13635-
Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer,
13635+
Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access,
1363613636
Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property);
1363713637
}
1363813638
return numberType;
@@ -13859,7 +13859,7 @@ namespace ts {
1385913859

1386013860
function checkReferenceAssignment(target: Expression, sourceType: Type, contextualMapper?: TypeMapper): Type {
1386113861
const targetType = checkExpression(target, contextualMapper);
13862-
if (checkReferenceExpression(target, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) {
13862+
if (checkReferenceExpression(target, Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) {
1386313863
checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined);
1386413864
}
1386513865
return sourceType;
@@ -14143,7 +14143,7 @@ namespace ts {
1414314143
// A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1)
1414414144
// and the type of the non - compound operation to be assignable to the type of VarExpr.
1414514145
const ok = checkReferenceExpression(left,
14146-
Diagnostics.Invalid_left_hand_side_of_assignment_expression,
14146+
Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access,
1414714147
Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property);
1414814148
// Use default messages
1414914149
if (ok) {
@@ -16588,7 +16588,7 @@ namespace ts {
1658816588
}
1658916589
else {
1659016590
const leftType = checkExpression(varExpr);
16591-
checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ Diagnostics.Invalid_left_hand_side_in_for_of_statement,
16591+
checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access,
1659216592
/*constantVariableMessage*/ Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property);
1659316593

1659416594
// iteratedType will be undefined if the rightType was missing properties/signatures
@@ -16639,7 +16639,7 @@ namespace ts {
1663916639
}
1664016640
else {
1664116641
// run check only former check succeeded to avoid cascading errors
16642-
checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_in_statement,
16642+
checkReferenceExpression(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access,
1664316643
Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property);
1664416644
}
1664516645
}

src/compiler/diagnosticMessages.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@
10751075
"category": "Error",
10761076
"code": 2356
10771077
},
1078-
"The operand of an increment or decrement operator must be a variable, property or indexer.": {
1078+
"The operand of an increment or decrement operator must be a variable or a property access.": {
10791079
"category": "Error",
10801080
"code": 2357
10811081
},
@@ -1103,7 +1103,7 @@
11031103
"category": "Error",
11041104
"code": 2363
11051105
},
1106-
"Invalid left-hand side of assignment expression.": {
1106+
"The left-hand side of an assignment expression must be a variable or a property access.": {
11071107
"category": "Error",
11081108
"code": 2364
11091109
},
@@ -1263,7 +1263,7 @@
12631263
"category": "Error",
12641264
"code": 2405
12651265
},
1266-
"Invalid left-hand side in 'for...in' statement.": {
1266+
"The left-hand side of a 'for...in' statement must be a variable or a property access.": {
12671267
"category": "Error",
12681268
"code": 2406
12691269
},
@@ -1563,7 +1563,7 @@
15631563
"category": "Error",
15641564
"code": 2486
15651565
},
1566-
"Invalid left-hand side in 'for...of' statement.": {
1566+
"The left-hand side of a 'for...of' statement must be a variable or a property access.": {
15671567
"category": "Error",
15681568
"code": 2487
15691569
},
@@ -1771,6 +1771,10 @@
17711771
"category": "Error",
17721772
"code": 2540
17731773
},
1774+
"The target of an assignment must be a variable or a property access.": {
1775+
"category": "Error",
1776+
"code": 2541
1777+
},
17741778
"JSX element attributes type '{0}' may not be a union type.": {
17751779
"category": "Error",
17761780
"code": 2600

0 commit comments

Comments
 (0)