Disallow destructuring in 'for...in'

This commit is contained in:
Jason Freeman
2015-02-26 18:16:21 -08:00
parent 84a22be433
commit fd0fd36597
17 changed files with 78 additions and 5 deletions

View File

@@ -0,0 +1,7 @@
tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts(1,10): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern.
==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring.ts (1 errors) ====
for (var [a, b] in []) {}
~~~~~~
!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern.

View File

@@ -0,0 +1,5 @@
//// [for-inStatementsDestructuring.ts]
for (var [a, b] in []) {}
//// [for-inStatementsDestructuring.js]
for (var _a = void 0, a = _a[0], b = _a[1] in []) { }

View File

@@ -0,0 +1,7 @@
tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts(1,10): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern.
==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring2.ts (1 errors) ====
for (var {a, b} in []) {}
~~~~~~
!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern.

View File

@@ -0,0 +1,5 @@
//// [for-inStatementsDestructuring2.ts]
for (var {a, b} in []) {}
//// [for-inStatementsDestructuring2.js]
for (var _a = void 0, a = _a.a, b = _a.b in []) { }

View File

@@ -0,0 +1,8 @@
tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring3.ts(2,6): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern.
==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring3.ts (1 errors) ====
var a, b;
for ([a, b] in []) { }
~~~~~~
!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern.

View File

@@ -0,0 +1,7 @@
//// [for-inStatementsDestructuring3.ts]
var a, b;
for ([a, b] in []) { }
//// [for-inStatementsDestructuring3.js]
var a, b;
for ([a, b] in []) { }

View File

@@ -0,0 +1,8 @@
tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring4.ts(2,6): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern.
==== tests/cases/conformance/statements/for-inStatements/for-inStatementsDestructuring4.ts (1 errors) ====
var a, b;
for ({a, b} in []) { }
~~~~~~
!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern.

View File

@@ -0,0 +1,7 @@
//// [for-inStatementsDestructuring4.ts]
var a, b;
for ({a, b} in []) { }
//// [for-inStatementsDestructuring4.js]
var a, b;
for ({ a: a, b: b } in []) { }

View File

@@ -1,11 +1,11 @@
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement5.ts(1,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement5.ts(1,6): error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern.
tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement5.ts(1,12): error TS2304: Cannot find name 'b'.
==== tests/cases/conformance/parser/ecmascript5/Statements/parserForStatement5.ts (2 errors) ====
for ({} in b) {
~~
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
!!! error TS2491: The left-hand side of a 'for...in' statement cannot be a destructuring pattern.
~
!!! error TS2304: Cannot find name 'b'.
}

View File

@@ -0,0 +1 @@
for (var [a, b] in []) {}

View File

@@ -0,0 +1 @@
for (var {a, b} in []) {}

View File

@@ -0,0 +1,2 @@
var a, b;
for ([a, b] in []) { }

View File

@@ -0,0 +1,2 @@
var a, b;
for ({a, b} in []) { }