Skip to content

Commit 5b46f5f

Browse files
committed
Remove error for using 'for...of' in ES3/ES5
1 parent b38743c commit 5b46f5f

51 files changed

Lines changed: 1043 additions & 578 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/compiler/checker.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8777,11 +8777,6 @@ module ts {
87778777
}
87788778

87798779
function checkForOfStatement(node: ForOfStatement): void {
8780-
if (languageVersion < ScriptTarget.ES6) {
8781-
grammarErrorOnFirstToken(node, Diagnostics.for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher);
8782-
return;
8783-
}
8784-
87858780
checkGrammarForInOrForOfStatement(node)
87868781

87878782
// Check the LHS and RHS

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ module ts {
327327
Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." },
328328
let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." },
329329
Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." },
330-
for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 2482, category: DiagnosticCategory.Error, key: "'for...of' statements are only available when targeting ECMAScript 6 or higher." },
331330
The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." },
332331
Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" },
333332
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." },

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,10 +1299,6 @@
12991299
"category": "Error",
13001300
"code": 2481
13011301
},
1302-
"'for...of' statements are only available when targeting ECMAScript 6 or higher.": {
1303-
"category": "Error",
1304-
"code": 2482
1305-
},
13061302
"The left-hand side of a 'for...of' statement cannot use a type annotation.": {
13071303
"category": "Error",
13081304
"code": 2483
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
1+
tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts(2,5): error TS2304: Cannot find name 'console'.
22

33

44
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts (1 errors) ====
55
for (var v of ['a', 'b', 'c']) {
6-
~~~
7-
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher.
86
console.log(v);
7+
~~~~~~~
8+
!!! error TS2304: Cannot find name 'console'.
99
}

tests/baselines/reference/ES5For-of10.errors.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/baselines/reference/ES5For-of11.errors.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/baselines/reference/ES5For-of13.errors.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

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

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/statements/for-ofStatements/ES5For-of14.ts ===
2+
for (const v of []) {
3+
>v : any
4+
>[] : undefined[]
5+
6+
var x = v;
7+
>x : any
8+
>v : any
9+
}

tests/baselines/reference/ES5For-of15.errors.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)