mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-27 22:39:59 -05:00
Disallow destructuring in 'for...in'
This commit is contained in:
@@ -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.
|
||||
@@ -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 []) { }
|
||||
@@ -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.
|
||||
@@ -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 []) { }
|
||||
@@ -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.
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [for-inStatementsDestructuring3.ts]
|
||||
var a, b;
|
||||
for ([a, b] in []) { }
|
||||
|
||||
//// [for-inStatementsDestructuring3.js]
|
||||
var a, b;
|
||||
for ([a, b] in []) { }
|
||||
@@ -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.
|
||||
@@ -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 []) { }
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
for (var [a, b] in []) {}
|
||||
@@ -0,0 +1 @@
|
||||
for (var {a, b} in []) {}
|
||||
@@ -0,0 +1,2 @@
|
||||
var a, b;
|
||||
for ([a, b] in []) { }
|
||||
@@ -0,0 +1,2 @@
|
||||
var a, b;
|
||||
for ({a, b} in []) { }
|
||||
Reference in New Issue
Block a user