/
noImplicitAnyForIn.errors.txt
49 lines (39 loc) · 2.14 KB
/
noImplicitAnyForIn.errors.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
tests/cases/compiler/noImplicitAnyForIn.ts(7,18): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'.
tests/cases/compiler/noImplicitAnyForIn.ts(14,18): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
No index signature with a parameter of type 'string' was found on type '{}'.
tests/cases/compiler/noImplicitAnyForIn.ts(28,5): error TS7005: Variable 'n' implicitly has an 'any[][]' type.
tests/cases/compiler/noImplicitAnyForIn.ts(30,6): error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
==== tests/cases/compiler/noImplicitAnyForIn.ts (4 errors) ====
var x: {}[] = [[1, 2, 3], ["hello"]];
for (var i in x) {
for (var j in x[i]) {
//Should yield an implicit 'any' error
var _j = x[i][j];
~~~~~~~
!!! error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
!!! error TS7053: No index signature with a parameter of type 'string' was found on type '{}'.
}
for (var k in x[0]) {
var k1 = x[0];
//Should yield an implicit 'any' error
var k2 = k1[k];
~~~~~
!!! error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
!!! error TS7053: No index signature with a parameter of type 'string' was found on type '{}'.
}
}
for (var a in x) {
// Should yield an implicit 'any' error.
var b;
var c = a || b;
}
var idx = 0;
var m = [1, 2, 3, 4, 5];
// Should yield an implicit 'any' error.
var n = [[]] || [];
~
!!! error TS7005: Variable 'n' implicitly has an 'any[][]' type.
for (n[idx++] in m);
~~~~~~~~
!!! error TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.