Skip to content

Commit cb97686

Browse files
committed
Add tests for scoping
1 parent 8da49aa commit cb97686

15 files changed

+102
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tests/cases/conformance/es6/for-ofStatements/for-of51.ts(1,10): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.
2+
3+
4+
==== tests/cases/conformance/es6/for-ofStatements/for-of51.ts (1 errors) ====
5+
for (let let of []) {}
6+
~~~
7+
!!! error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations.

tests/baselines/reference/for-of51.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//// [for-of51.ts]
2+
for (let let of []) {}
3+
4+
//// [for-of51.js]
5+
for (let let of []) { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/conformance/es6/for-ofStatements/for-of52.ts(1,11): error TS2451: Cannot redeclare block-scoped variable 'v'.
2+
tests/cases/conformance/es6/for-ofStatements/for-of52.ts(1,14): error TS2451: Cannot redeclare block-scoped variable 'v'.
3+
4+
5+
==== tests/cases/conformance/es6/for-ofStatements/for-of52.ts (2 errors) ====
6+
for (let [v, v] of [[]]) {}
7+
~
8+
!!! error TS2451: Cannot redeclare block-scoped variable 'v'.
9+
~
10+
!!! error TS2451: Cannot redeclare block-scoped variable 'v'.

tests/baselines/reference/for-of52.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//// [for-of52.ts]
2+
for (let [v, v] of [[]]) {}
3+
4+
//// [for-of52.js]
5+
for (let [v, v] of [[]]) { }

tests/baselines/reference/for-of53.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [for-of53.ts]
2+
for (let v of []) {
3+
var v;
4+
}
5+
6+
//// [for-of53.js]
7+
for (let v of []) {
8+
var v;
9+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/conformance/es6/for-ofStatements/for-of53.ts ===
2+
for (let v of []) {
3+
>v : any
4+
>[] : undefined[]
5+
6+
var v;
7+
>v : any
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests/cases/conformance/es6/for-ofStatements/for-of54.ts(2,9): error TS2481: Cannot initialize outer scoped variable 'v' in the same scope as block scoped declaration 'v'.
2+
3+
4+
==== tests/cases/conformance/es6/for-ofStatements/for-of54.ts (1 errors) ====
5+
for (let v of []) {
6+
var v = 0;
7+
~
8+
!!! error TS2481: Cannot initialize outer scoped variable 'v' in the same scope as block scoped declaration 'v'.
9+
}

tests/baselines/reference/for-of54.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [for-of54.ts]
2+
for (let v of []) {
3+
var v = 0;
4+
}
5+
6+
//// [for-of54.js]
7+
for (let v of []) {
8+
var v = 0;
9+
}

tests/baselines/reference/for-of55.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [for-of55.ts]
2+
let v = [1];
3+
for (let v of v) {
4+
v;
5+
}
6+
7+
//// [for-of55.js]
8+
let v = [1];
9+
for (let v of v) {
10+
v;
11+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/conformance/es6/for-ofStatements/for-of55.ts ===
2+
let v = [1];
3+
>v : number[]
4+
>[1] : number[]
5+
6+
for (let v of v) {
7+
>v : any
8+
>v : any
9+
10+
v;
11+
>v : any
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//@target: ES6
2+
for (let let of []) {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//@target: ES6
2+
for (let [v, v] of [[]]) {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@target: ES6
2+
for (let v of []) {
3+
var v;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@target: ES6
2+
for (let v of []) {
3+
var v = 0;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@target: ES6
2+
let v = [1];
3+
for (let v of v) {
4+
v;
5+
}

0 commit comments

Comments
 (0)