Skip to content

Commit 0436ba0

Browse files
Merge pull request #7165 from Microsoft/add-tests-for-let
Add tests for let declarations/identifier variables
2 parents 9d65642 + c03aace commit 0436ba0

11 files changed

+91
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [VariableDeclaration12_es6.ts]
2+
3+
let
4+
x
5+
6+
//// [VariableDeclaration12_es6.js]
7+
let x;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration12_es6.ts ===
2+
3+
let
4+
x
5+
>x : Symbol(x, Decl(VariableDeclaration12_es6.ts, 1, 3))
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration12_es6.ts ===
2+
3+
let
4+
x
5+
>x : any
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,5): error TS1181: Array element destructuring pattern expected.
2+
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,6): error TS1005: ',' expected.
3+
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,8): error TS1134: Variable declaration expected.
4+
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,10): error TS1134: Variable declaration expected.
5+
6+
7+
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts (4 errors) ====
8+
9+
// An ExpressionStatement cannot start with the two token sequence `let [` because
10+
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
11+
var let: any;
12+
let[0] = 100;
13+
~
14+
!!! error TS1181: Array element destructuring pattern expected.
15+
~
16+
!!! error TS1005: ',' expected.
17+
~
18+
!!! error TS1134: Variable declaration expected.
19+
~~~
20+
!!! error TS1134: Variable declaration expected.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [VariableDeclaration13_es6.ts]
2+
3+
// An ExpressionStatement cannot start with the two token sequence `let [` because
4+
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
5+
var let: any;
6+
let[0] = 100;
7+
8+
//// [VariableDeclaration13_es6.js]
9+
// An ExpressionStatement cannot start with the two token sequence `let [` because
10+
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
11+
var let;
12+
let [] = 0;
13+
100;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [letIdentifierInElementAccess01.ts]
2+
var let: any = {};
3+
(let[0] = 100);
4+
5+
//// [letIdentifierInElementAccess01.js]
6+
var let = {};
7+
(let[0] = 100);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/conformance/expressions/elementAccess/letIdentifierInElementAccess01.ts ===
2+
var let: any = {};
3+
>let : Symbol(let, Decl(letIdentifierInElementAccess01.ts, 0, 3))
4+
5+
(let[0] = 100);
6+
>let : Symbol(let, Decl(letIdentifierInElementAccess01.ts, 0, 3))
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/conformance/expressions/elementAccess/letIdentifierInElementAccess01.ts ===
2+
var let: any = {};
3+
>let : any
4+
>{} : {}
5+
6+
(let[0] = 100);
7+
>(let[0] = 100) : number
8+
>let[0] = 100 : number
9+
>let[0] : any
10+
>let : any
11+
>0 : number
12+
>100 : number
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @target:es6
2+
3+
let
4+
x
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @target:es6
2+
3+
// An ExpressionStatement cannot start with the two token sequence `let [` because
4+
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
5+
var let: any;
6+
let[0] = 100;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
var let: any = {};
2+
(let[0] = 100);

0 commit comments

Comments
 (0)