-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2207 from Microsoft/for-ofES5
Emit 'for...of' statements in ES3/ES5
- Loading branch information
Showing
133 changed files
with
2,109 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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. | ||
|
||
|
||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts (1 errors) ==== | ||
for (var v of ['a', 'b', 'c']) { | ||
~~~ | ||
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. | ||
console.log(v); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
=================================================================== | ||
JsFile: ES5For-of1.js | ||
mapUrl: ES5For-of1.js.map | ||
sourceRoot: | ||
sources: ES5For-of1.ts | ||
=================================================================== | ||
------------------------------------------------------------------- | ||
emittedFile:tests/cases/conformance/statements/for-ofStatements/ES5For-of1.js | ||
sourceFile:ES5For-of1.ts | ||
------------------------------------------------------------------- | ||
>>>for (var _i = 0, _a = [ | ||
1 > | ||
2 >^^^ | ||
3 > ^ | ||
4 > ^ | ||
5 > ^^^^^^^^^^ | ||
6 > ^^ | ||
1 > | ||
2 >for | ||
3 > | ||
4 > (var v of | ||
5 > ['a', 'b', 'c'] | ||
6 > | ||
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) | ||
2 >Emitted(1, 4) Source(1, 4) + SourceIndex(0) | ||
3 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) | ||
4 >Emitted(1, 6) Source(1, 15) + SourceIndex(0) | ||
5 >Emitted(1, 16) Source(1, 30) + SourceIndex(0) | ||
6 >Emitted(1, 18) Source(1, 15) + SourceIndex(0) | ||
--- | ||
>>> 'a', | ||
1 >^^^^ | ||
2 > ^^^ | ||
3 > ^^-> | ||
1 >[ | ||
2 > 'a' | ||
1 >Emitted(2, 5) Source(1, 16) + SourceIndex(0) | ||
2 >Emitted(2, 8) Source(1, 19) + SourceIndex(0) | ||
--- | ||
>>> 'b', | ||
1->^^^^ | ||
2 > ^^^ | ||
3 > ^-> | ||
1->, | ||
2 > 'b' | ||
1->Emitted(3, 5) Source(1, 21) + SourceIndex(0) | ||
2 >Emitted(3, 8) Source(1, 24) + SourceIndex(0) | ||
--- | ||
>>> 'c' | ||
1->^^^^ | ||
2 > ^^^ | ||
3 > ^^^^^^^^^^^^^^^^^^^^-> | ||
1->, | ||
2 > 'c' | ||
1->Emitted(4, 5) Source(1, 26) + SourceIndex(0) | ||
2 >Emitted(4, 8) Source(1, 29) + SourceIndex(0) | ||
--- | ||
>>>]; _i < _a.length; _i++) { | ||
1->^ | ||
2 > ^^ | ||
3 > ^^^^^^^^^^^^^^ | ||
4 > ^^ | ||
5 > ^^^^ | ||
6 > ^ | ||
1->] | ||
2 > | ||
3 > var v | ||
4 > | ||
5 > var v of ['a', 'b', 'c'] | ||
6 > ) | ||
1->Emitted(5, 2) Source(1, 30) + SourceIndex(0) | ||
2 >Emitted(5, 4) Source(1, 6) + SourceIndex(0) | ||
3 >Emitted(5, 18) Source(1, 11) + SourceIndex(0) | ||
4 >Emitted(5, 20) Source(1, 6) + SourceIndex(0) | ||
5 >Emitted(5, 24) Source(1, 30) + SourceIndex(0) | ||
6 >Emitted(5, 25) Source(1, 31) + SourceIndex(0) | ||
--- | ||
>>> var v = _a[_i]; | ||
1 >^^^^ | ||
2 > ^^^^ | ||
3 > ^ | ||
4 > ^^^^^^^^^ | ||
5 > ^^-> | ||
1 > | ||
2 > var | ||
3 > v | ||
4 > | ||
1 >Emitted(6, 5) Source(1, 6) + SourceIndex(0) | ||
2 >Emitted(6, 9) Source(1, 10) + SourceIndex(0) | ||
3 >Emitted(6, 10) Source(1, 11) + SourceIndex(0) | ||
4 >Emitted(6, 19) Source(1, 11) + SourceIndex(0) | ||
--- | ||
>>> console.log(v); | ||
1->^^^^ | ||
2 > ^^^^^^^ | ||
3 > ^ | ||
4 > ^^^ | ||
5 > ^ | ||
6 > ^ | ||
7 > ^ | ||
8 > ^ | ||
1-> of ['a', 'b', 'c']) { | ||
> | ||
2 > console | ||
3 > . | ||
4 > log | ||
5 > ( | ||
6 > v | ||
7 > ) | ||
8 > ; | ||
1->Emitted(7, 5) Source(2, 5) + SourceIndex(0) | ||
2 >Emitted(7, 12) Source(2, 12) + SourceIndex(0) | ||
3 >Emitted(7, 13) Source(2, 13) + SourceIndex(0) | ||
4 >Emitted(7, 16) Source(2, 16) + SourceIndex(0) | ||
5 >Emitted(7, 17) Source(2, 17) + SourceIndex(0) | ||
6 >Emitted(7, 18) Source(2, 18) + SourceIndex(0) | ||
7 >Emitted(7, 19) Source(2, 19) + SourceIndex(0) | ||
8 >Emitted(7, 20) Source(2, 20) + SourceIndex(0) | ||
--- | ||
>>>} | ||
1 >^ | ||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> | ||
1 > | ||
>} | ||
1 >Emitted(8, 2) Source(3, 2) + SourceIndex(0) | ||
--- | ||
>>>//# sourceMappingURL=ES5For-of1.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts(4,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. | ||
|
||
|
||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of10.ts (1 errors) ==== | ||
function foo() { | ||
return { x: 0 }; | ||
} | ||
for (foo().x of []) { | ||
~~~ | ||
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. | ||
for (foo().x of []) | ||
var p = foo().x; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//// [ES5For-of10.ts] | ||
function foo() { | ||
return { x: 0 }; | ||
} | ||
for (foo().x of []) { | ||
for (foo().x of []) | ||
var p = foo().x; | ||
} | ||
|
||
//// [ES5For-of10.js] | ||
function foo() { | ||
return { | ||
x: 0 | ||
}; | ||
} | ||
for (var _i = 0, _a = []; _i < _a.length; _i++) { | ||
foo().x = _a[_i]; | ||
for (var _b = 0, _c = []; _b < _c.length; _b++) { | ||
foo().x = _c[_b]; | ||
var p = foo().x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts(2,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. | ||
|
||
|
||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of11.ts (1 errors) ==== | ||
var v; | ||
for (v of []) { } | ||
~~~ | ||
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//// [ES5For-of11.ts] | ||
var v; | ||
for (v of []) { } | ||
|
||
//// [ES5For-of11.js] | ||
var v; | ||
for (var _i = 0, _a = []; _i < _a.length; _i++) { | ||
v = _a[_i]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. | ||
|
||
|
||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts (1 errors) ==== | ||
for ([""] of []) { } | ||
~~~ | ||
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//// [ES5For-of12.ts] | ||
for ([""] of []) { } | ||
|
||
//// [ES5For-of12.js] | ||
for (var _i = 0, _a = []; _i < _a.length; _i++) { | ||
"" = _a[_i][0]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts(1,1): error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. | ||
|
||
|
||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of13.ts (1 errors) ==== | ||
for (let v of ['a', 'b', 'c']) { | ||
~~~ | ||
!!! error TS2482: 'for...of' statements are only available when targeting ECMAScript 6 or higher. | ||
var x = v; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
=================================================================== | ||
JsFile: ES5For-of13.js | ||
mapUrl: ES5For-of13.js.map | ||
sourceRoot: | ||
sources: ES5For-of13.ts | ||
=================================================================== | ||
------------------------------------------------------------------- | ||
emittedFile:tests/cases/conformance/statements/for-ofStatements/ES5For-of13.js | ||
sourceFile:ES5For-of13.ts | ||
------------------------------------------------------------------- | ||
>>>for (var _i = 0, _a = [ | ||
1 > | ||
2 >^^^ | ||
3 > ^ | ||
4 > ^ | ||
5 > ^^^^^^^^^^ | ||
6 > ^^ | ||
1 > | ||
2 >for | ||
3 > | ||
4 > (let v of | ||
5 > ['a', 'b', 'c'] | ||
6 > | ||
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) | ||
2 >Emitted(1, 4) Source(1, 4) + SourceIndex(0) | ||
3 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) | ||
4 >Emitted(1, 6) Source(1, 15) + SourceIndex(0) | ||
5 >Emitted(1, 16) Source(1, 30) + SourceIndex(0) | ||
6 >Emitted(1, 18) Source(1, 15) + SourceIndex(0) | ||
--- | ||
>>> 'a', | ||
1 >^^^^ | ||
2 > ^^^ | ||
3 > ^^-> | ||
1 >[ | ||
2 > 'a' | ||
1 >Emitted(2, 5) Source(1, 16) + SourceIndex(0) | ||
2 >Emitted(2, 8) Source(1, 19) + SourceIndex(0) | ||
--- | ||
>>> 'b', | ||
1->^^^^ | ||
2 > ^^^ | ||
3 > ^-> | ||
1->, | ||
2 > 'b' | ||
1->Emitted(3, 5) Source(1, 21) + SourceIndex(0) | ||
2 >Emitted(3, 8) Source(1, 24) + SourceIndex(0) | ||
--- | ||
>>> 'c' | ||
1->^^^^ | ||
2 > ^^^ | ||
3 > ^^^^^^^^^^^^^^^^^^^^-> | ||
1->, | ||
2 > 'c' | ||
1->Emitted(4, 5) Source(1, 26) + SourceIndex(0) | ||
2 >Emitted(4, 8) Source(1, 29) + SourceIndex(0) | ||
--- | ||
>>>]; _i < _a.length; _i++) { | ||
1->^ | ||
2 > ^^ | ||
3 > ^^^^^^^^^^^^^^ | ||
4 > ^^ | ||
5 > ^^^^ | ||
6 > ^ | ||
1->] | ||
2 > | ||
3 > let v | ||
4 > | ||
5 > let v of ['a', 'b', 'c'] | ||
6 > ) | ||
1->Emitted(5, 2) Source(1, 30) + SourceIndex(0) | ||
2 >Emitted(5, 4) Source(1, 6) + SourceIndex(0) | ||
3 >Emitted(5, 18) Source(1, 11) + SourceIndex(0) | ||
4 >Emitted(5, 20) Source(1, 6) + SourceIndex(0) | ||
5 >Emitted(5, 24) Source(1, 30) + SourceIndex(0) | ||
6 >Emitted(5, 25) Source(1, 31) + SourceIndex(0) | ||
--- | ||
>>> var v = _a[_i]; | ||
1 >^^^^ | ||
2 > ^^^^ | ||
3 > ^ | ||
4 > ^^^^^^^^^ | ||
1 > | ||
2 > let | ||
3 > v | ||
4 > | ||
1 >Emitted(6, 5) Source(1, 6) + SourceIndex(0) | ||
2 >Emitted(6, 9) Source(1, 10) + SourceIndex(0) | ||
3 >Emitted(6, 10) Source(1, 11) + SourceIndex(0) | ||
4 >Emitted(6, 19) Source(1, 11) + SourceIndex(0) | ||
--- | ||
>>> var x = v; | ||
1 >^^^^ | ||
2 > ^^^^ | ||
3 > ^ | ||
4 > ^^^ | ||
5 > ^ | ||
6 > ^ | ||
1 > of ['a', 'b', 'c']) { | ||
> | ||
2 > var | ||
3 > x | ||
4 > = | ||
5 > v | ||
6 > ; | ||
1 >Emitted(7, 5) Source(2, 5) + SourceIndex(0) | ||
2 >Emitted(7, 9) Source(2, 9) + SourceIndex(0) | ||
3 >Emitted(7, 10) Source(2, 10) + SourceIndex(0) | ||
4 >Emitted(7, 13) Source(2, 13) + SourceIndex(0) | ||
5 >Emitted(7, 14) Source(2, 14) + SourceIndex(0) | ||
6 >Emitted(7, 15) Source(2, 15) + SourceIndex(0) | ||
--- | ||
>>>} | ||
1 >^ | ||
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> | ||
1 > | ||
>} | ||
1 >Emitted(8, 2) Source(3, 2) + SourceIndex(0) | ||
--- | ||
>>>//# sourceMappingURL=ES5For-of13.js.map |
Oops, something went wrong.
Quite confusing comment.
Written for people who already know why this assertion is there. It closely repeats the assertion message with a puzzling variation of wording.
Either it should be clearer (telling why calling isUnknownIdentifier on synthesized location is wrong), or removed.