diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 12d6d32e1ad..a3af265b359 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5213,7 +5213,7 @@ module ts { if (node.declaration) { checkVariableDeclaration(node.declaration); if (node.declaration.type) { - error(node.declaration, Diagnostics.Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation); + error(node.declaration, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation); } } @@ -5224,7 +5224,7 @@ module ts { if (node.variable) { var exprType = checkExpression(node.variable); if (exprType !== anyType && exprType !== stringType) { - error(node.variable, Diagnostics.Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any); + error(node.variable, Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { // run check only former check succeeded to avoid cascading errors diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index b243ef02d1d..c0c2347bb0a 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -114,8 +114,8 @@ module ts { The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2112, category: DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2113, category: DiagnosticCategory.Error, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2114, category: DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - Variable_declarations_of_a_for_statement_cannot_use_a_type_annotation: { code: 2115, category: DiagnosticCategory.Error, key: "Variable declarations of a 'for' statement cannot use a type annotation." }, - Variable_declarations_of_a_for_statement_must_be_of_types_string_or_any: { code: 2116, category: DiagnosticCategory.Error, key: "Variable declarations of a 'for' statement must be of types 'string' or 'any'." }, + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2115, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2116, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2117, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number: { code: 2118, category: DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'." }, The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2119, category: DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c088fd4eddc..51260ccd6ef 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -448,11 +448,11 @@ "category": "Error", "code": 2114 }, - "Variable declarations of a 'for' statement cannot use a type annotation.": { + "The left-hand side of a 'for...in' statement cannot use a type annotation.": { "category": "Error", "code": 2115 }, - "Variable declarations of a 'for' statement must be of types 'string' or 'any'.": { + "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.": { "category": "Error", "code": 2116 }, diff --git a/tests/baselines/reference/for-inStatementsInvalid.errors.txt b/tests/baselines/reference/for-inStatementsInvalid.errors.txt index cd47a9297ca..4b4fff8c51c 100644 --- a/tests/baselines/reference/for-inStatementsInvalid.errors.txt +++ b/tests/baselines/reference/for-inStatementsInvalid.errors.txt @@ -2,21 +2,21 @@ var aNumber: number; for (aNumber in {}) { } ~~~~~~~ -!!! Variable declarations of a 'for' statement must be of types 'string' or 'any'. +!!! The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. var aBoolean: boolean; for (aBoolean in {}) { } ~~~~~~~~ -!!! Variable declarations of a 'for' statement must be of types 'string' or 'any'. +!!! The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. var aRegExp: RegExp; for (aRegExp in {}) { } ~~~~~~~ -!!! Variable declarations of a 'for' statement must be of types 'string' or 'any'. +!!! The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. for (var idx : number in {}) { } ~~~ -!!! Variable declarations of a 'for' statement cannot use a type annotation. +!!! The left-hand side of a 'for...in' statement cannot use a type annotation. function fn(): void { } for (var x in fn()) { } diff --git a/tests/baselines/reference/forIn.errors.txt b/tests/baselines/reference/forIn.errors.txt index e6d33b50277..51a3b220359 100644 --- a/tests/baselines/reference/forIn.errors.txt +++ b/tests/baselines/reference/forIn.errors.txt @@ -2,7 +2,7 @@ var arr = null; for (var i:number in arr) { // error ~ -!!! Variable declarations of a 'for' statement cannot use a type annotation. +!!! The left-hand side of a 'for...in' statement cannot use a type annotation. var x1 = arr[i]; var y1 = arr[i]; } diff --git a/tests/baselines/reference/forInStatement4.errors.txt b/tests/baselines/reference/forInStatement4.errors.txt index 433fa89d535..b228fb93c89 100644 --- a/tests/baselines/reference/forInStatement4.errors.txt +++ b/tests/baselines/reference/forInStatement4.errors.txt @@ -2,5 +2,5 @@ var expr: any; for (var a: number in expr) { ~ -!!! Variable declarations of a 'for' statement cannot use a type annotation. +!!! The left-hand side of a 'for...in' statement cannot use a type annotation. } \ No newline at end of file diff --git a/tests/baselines/reference/forInStatement7.errors.txt b/tests/baselines/reference/forInStatement7.errors.txt index 8e75078d9e8..432fe82237f 100644 --- a/tests/baselines/reference/forInStatement7.errors.txt +++ b/tests/baselines/reference/forInStatement7.errors.txt @@ -3,5 +3,5 @@ var expr: any; for (a in expr) { ~ -!!! Variable declarations of a 'for' statement must be of types 'string' or 'any'. +!!! The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. } \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyForIn.errors.txt b/tests/baselines/reference/noImplicitAnyForIn.errors.txt index e06c7522cf8..7e4122a8f26 100644 --- a/tests/baselines/reference/noImplicitAnyForIn.errors.txt +++ b/tests/baselines/reference/noImplicitAnyForIn.errors.txt @@ -39,4 +39,4 @@ for (n[idx++] in m); ~~~~~~~~ -!!! Variable declarations of a 'for' statement must be of types 'string' or 'any'. \ No newline at end of file +!!! The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. \ No newline at end of file diff --git a/tests/baselines/reference/parserForInStatement5.errors.txt b/tests/baselines/reference/parserForInStatement5.errors.txt index 6da9d681a55..d9512576b7b 100644 --- a/tests/baselines/reference/parserForInStatement5.errors.txt +++ b/tests/baselines/reference/parserForInStatement5.errors.txt @@ -1,7 +1,7 @@ ==== tests/cases/conformance/parser/ecmascript5/Statements/parserForInStatement5.ts (2 errors) ==== for (var a: number in X) { ~ -!!! Variable declarations of a 'for' statement cannot use a type annotation. +!!! The left-hand side of a 'for...in' statement cannot use a type annotation. ~ !!! Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForInStatement7.errors.txt b/tests/baselines/reference/parserForInStatement7.errors.txt index f5b5451f8a8..d1c039c751b 100644 --- a/tests/baselines/reference/parserForInStatement7.errors.txt +++ b/tests/baselines/reference/parserForInStatement7.errors.txt @@ -3,7 +3,7 @@ ~ !!! Only a single variable declaration is allowed in a 'for...in' statement. ~ -!!! Variable declarations of a 'for' statement cannot use a type annotation. +!!! The left-hand side of a 'for...in' statement cannot use a type annotation. ~ !!! Cannot find name 'X'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForStatement3.errors.txt b/tests/baselines/reference/parserForStatement3.errors.txt index eab0e8e6805..8af66924fc0 100644 --- a/tests/baselines/reference/parserForStatement3.errors.txt +++ b/tests/baselines/reference/parserForStatement3.errors.txt @@ -1,7 +1,7 @@ ==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement3.ts (7 errors) ==== for(d in _.jh[a]=_.jh[a]||[],b); ~ -!!! Variable declarations of a 'for' statement must be of types 'string' or 'any'. +!!! The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. ~ !!! Cannot find name 'd'. ~ diff --git a/tests/baselines/reference/parserForStatement4.errors.txt b/tests/baselines/reference/parserForStatement4.errors.txt index 69dc6388c63..923b05341b5 100644 --- a/tests/baselines/reference/parserForStatement4.errors.txt +++ b/tests/baselines/reference/parserForStatement4.errors.txt @@ -3,7 +3,7 @@ ~ !!! Cannot find name 'a'. ~~~~~ -!!! Variable declarations of a 'for' statement must be of types 'string' or 'any'. +!!! The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. ~ !!! Cannot find name 'b'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForStatement5.errors.txt b/tests/baselines/reference/parserForStatement5.errors.txt index c3b2ee8d3b7..e1d52c58ab6 100644 --- a/tests/baselines/reference/parserForStatement5.errors.txt +++ b/tests/baselines/reference/parserForStatement5.errors.txt @@ -1,7 +1,7 @@ ==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement5.ts (2 errors) ==== for ({} in b) { ~~ -!!! Variable declarations of a 'for' statement must be of types 'string' or 'any'. +!!! The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. ~ !!! Cannot find name 'b'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForStatement6.errors.txt b/tests/baselines/reference/parserForStatement6.errors.txt index 433ce9c43c6..cb758f34359 100644 --- a/tests/baselines/reference/parserForStatement6.errors.txt +++ b/tests/baselines/reference/parserForStatement6.errors.txt @@ -3,7 +3,7 @@ ~~~ !!! Cannot find name 'foo'. ~~~~~ -!!! Variable declarations of a 'for' statement must be of types 'string' or 'any'. +!!! The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. ~ !!! Cannot find name 'b'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserForStatement7.errors.txt b/tests/baselines/reference/parserForStatement7.errors.txt index 19580a0039b..0b1eeba1e05 100644 --- a/tests/baselines/reference/parserForStatement7.errors.txt +++ b/tests/baselines/reference/parserForStatement7.errors.txt @@ -1,7 +1,7 @@ ==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement7.ts (3 errors) ==== for (new foo() in b) { ~~~~~~~~~ -!!! Variable declarations of a 'for' statement must be of types 'string' or 'any'. +!!! The left-hand side of a 'for...in' statement must be of type 'string' or 'any'. ~~~ !!! Cannot find name 'foo'. ~