Skip to content

Commit 809706b

Browse files
committed
Test self-assignment w/array spread in loop
1 parent a52805f commit 809706b

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tests/cases/compiler/selfReferencingSpreadInLoop.ts(1,5): error TS7034: Variable 'additional' implicitly has type 'any[]' in some locations where its type cannot be determined.
2+
tests/cases/compiler/selfReferencingSpreadInLoop.ts(3,22): error TS7005: Variable 'additional' implicitly has an 'any[]' type.
3+
4+
5+
==== tests/cases/compiler/selfReferencingSpreadInLoop.ts (2 errors) ====
6+
let additional = [];
7+
~~~~~~~~~~
8+
!!! error TS7034: Variable 'additional' implicitly has type 'any[]' in some locations where its type cannot be determined.
9+
for (const subcomponent of [1, 2, 3]) {
10+
additional = [...additional, subcomponent];
11+
~~~~~~~~~~
12+
!!! error TS7005: Variable 'additional' implicitly has an 'any[]' type.
13+
}
14+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [selfReferencingSpreadInLoop.ts]
2+
let additional = [];
3+
for (const subcomponent of [1, 2, 3]) {
4+
additional = [...additional, subcomponent];
5+
}
6+
7+
8+
//// [selfReferencingSpreadInLoop.js]
9+
var additional = [];
10+
for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) {
11+
var subcomponent = _a[_i];
12+
additional = additional.concat([subcomponent]);
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @noImplicitAny: true
2+
let additional = [];
3+
for (const subcomponent of [1, 2, 3]) {
4+
additional = [...additional, subcomponent];
5+
}

0 commit comments

Comments
 (0)