Skip to content

Commit abe4076

Browse files
committed
Change error message to be more general
1 parent 8610a88 commit abe4076

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9320,7 +9320,7 @@ module ts {
93209320
let iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray;
93219321
if (iteratorFunctionSignatures.length === 0) {
93229322
if (expressionForError) {
9323-
error(expressionForError, Diagnostics.The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator);
9323+
error(expressionForError, Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator);
93249324
}
93259325
return undefined;
93269326
}
@@ -9338,7 +9338,7 @@ module ts {
93389338
let iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray;
93399339
if (iteratorNextFunctionSignatures.length === 0) {
93409340
if (expressionForError) {
9341-
error(expressionForError, Diagnostics.The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method);
9341+
error(expressionForError, Diagnostics.An_iterator_must_have_a_next_method);
93429342
}
93439343
return undefined;
93449344
}

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ module ts {
340340
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." },
341341
The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." },
342342
Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." },
343-
The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." },
344-
The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." },
343+
Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." },
344+
An_iterator_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." },
345345
The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." },
346346
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." },
347347
Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" },

src/compiler/diagnosticMessages.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,11 +1352,11 @@
13521352
"category": "Error",
13531353
"code": 2487
13541354
},
1355-
"The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.": {
1355+
"Type must have a '[Symbol.iterator]()' method that returns an iterator.": {
13561356
"category": "Error",
13571357
"code": 2488
13581358
},
1359-
"The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.": {
1359+
"An iterator must have a 'next()' method.": {
13601360
"category": "Error",
13611361
"code": 2489
13621362
},

tests/baselines/reference/for-of14.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
tests/cases/conformance/es6/for-ofStatements/for-of14.ts(2,11): error TS2488: The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.
1+
tests/cases/conformance/es6/for-ofStatements/for-of14.ts(2,11): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
22

33

44
==== tests/cases/conformance/es6/for-ofStatements/for-of14.ts (1 errors) ====
55
var v: string;
66
for (v of new StringIterator) { } // Should fail because the iterator is not iterable
77
~~~~~~~~~~~~~~~~~~
8-
!!! error TS2488: The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.
8+
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
99

1010
class StringIterator {
1111
next() {

tests/baselines/reference/for-of16.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
tests/cases/conformance/es6/for-ofStatements/for-of16.ts(2,11): error TS2489: The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.
1+
tests/cases/conformance/es6/for-ofStatements/for-of16.ts(2,11): error TS2489: An iterator must have a 'next()' method.
22

33

44
==== tests/cases/conformance/es6/for-ofStatements/for-of16.ts (1 errors) ====
55
var v: string;
66
for (v of new StringIterator) { } // Should fail
77
~~~~~~~~~~~~~~~~~~
8-
!!! error TS2489: The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.
8+
!!! error TS2489: An iterator must have a 'next()' method.
99

1010
class StringIterator {
1111
[Symbol.iterator]() {

0 commit comments

Comments
 (0)