From d3be38ea2f027dd16a88aa2026bbb58ecbec2d38 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 18 Jan 2016 17:56:58 -0800 Subject: [PATCH] Updating error messages --- src/compiler/checker.ts | 15 +++++++++------ src/compiler/diagnosticMessages.json | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 937065cd559..e762d915cec 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10476,7 +10476,7 @@ namespace ts { // run check only if former checks succeeded to avoid reporting cascading errors checkReferenceExpression(node.operand, Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, - Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); + Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); } return numberType; } @@ -10490,7 +10490,7 @@ namespace ts { // run check only if former checks succeeded to avoid reporting cascading errors checkReferenceExpression(node.operand, Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, - Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); + Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); } return numberType; } @@ -10681,7 +10681,7 @@ namespace ts { function checkReferenceAssignment(target: Expression, sourceType: Type, contextualMapper?: TypeMapper): Type { const targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant)) { + 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)) { checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; @@ -10863,7 +10863,9 @@ namespace ts { // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. - const ok = checkReferenceExpression(left, Diagnostics.Invalid_left_hand_side_of_assignment_expression, Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); + const ok = checkReferenceExpression(left, + Diagnostics.Invalid_left_hand_side_of_assignment_expression, + Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); // Use default messages if (ok) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported @@ -12935,7 +12937,7 @@ namespace ts { else { const leftType = checkExpression(varExpr); checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ Diagnostics.Invalid_left_hand_side_in_for_of_statement, - /*constantVariableMessage*/ Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant); + /*constantVariableMessage*/ Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be @@ -12982,7 +12984,8 @@ namespace ts { } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_in_statement, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant); + checkReferenceExpression(varExpr, Diagnostics.Invalid_left_hand_side_in_for_in_statement, + Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fc4aae4ed30..7392035ecda 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1395,11 +1395,11 @@ "category": "Error", "code": 2448 }, - "The operand of an increment or decrement operator cannot be a constant.": { + "The operand of an increment or decrement operator cannot be a constant or a read-only property.": { "category": "Error", "code": 2449 }, - "Left-hand side of assignment expression cannot be a constant.": { + "Left-hand side of assignment expression cannot be a constant or a read-only property.": { "category": "Error", "code": 2450 }, @@ -1531,11 +1531,11 @@ "category": "Error", "code": 2484 }, - "The left-hand side of a 'for...of' statement cannot be a previously defined constant.": { + "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.": { "category": "Error", "code": 2485 }, - "The left-hand side of a 'for...in' statement cannot be a previously defined constant.": { + "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property.": { "category": "Error", "code": 2486 },