Skip to content

Commit cab6e04

Browse files
committed
add new baseline tests
1 parent 5256ff7 commit cab6e04

5 files changed

+93
-49
lines changed
Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
11
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(1,9): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature.
2-
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(8,1): error TS7043: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'c.get' ?
3-
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(14,1): error TS7043: Element implicitly has an 'any' type because type '{ set: (key: string) => string; }' has no index signature. Did you mean to call 'd.set' ?
4-
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(21,1): error TS7043: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'e.get or e.set' ?
2+
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(7,1): error TS7052: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'get' ?
3+
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(8,13): error TS7052: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'get' ?
4+
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(13,13): error TS7017: Element implicitly has an 'any' type because type '{ set: (key: string) => string; }' has no index signature.
5+
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(19,1): error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ?
6+
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(20,1): error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ?
7+
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(21,1): error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ?
58

69

7-
==== tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts (4 errors) ====
10+
==== tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts (7 errors) ====
811
var a = {}["hello"];
912
~~~~~~~~~~~
1013
!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature.
1114
var b: string = { '': 'foo' }[''];
1215

13-
// Should give suggestion 'c.get'
1416
var c = {
1517
get: (key: string) => 'foobar'
1618
};
1719
c['hello'];
1820
~~~~~~~~~~
19-
!!! error TS7043: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'c.get' ?
21+
!!! error TS7052: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'get' ?
22+
const foo = c['hello'];
23+
~~~~~~~~~~
24+
!!! error TS7052: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'get' ?
2025

21-
// Should give suggestion 'd.set'
2226
var d = {
2327
set: (key: string) => 'foobar'
2428
};
25-
d['hello'];
26-
~~~~~~~~~~
27-
!!! error TS7043: Element implicitly has an 'any' type because type '{ set: (key: string) => string; }' has no index signature. Did you mean to call 'd.set' ?
29+
const bar = d['hello'];
30+
~~~~~~~~~~
31+
!!! error TS7017: Element implicitly has an 'any' type because type '{ set: (key: string) => string; }' has no index signature.
2832

29-
// Should give suggestion 'e.get or e.set'
3033
var e = {
3134
set: (key: string) => 'foobar',
3235
get: (key: string) => 'foobar'
3336
};
34-
e['hello'];
37+
e['hello'] = 'modified';
38+
~~~~~~~~~~
39+
!!! error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ?
40+
e['hello'] += 1;
3541
~~~~~~~~~~
36-
!!! error TS7043: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'e.get or e.set' ?
42+
!!! error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ?
43+
e['hello'] ++;
44+
~~~~~~~~~~
45+
!!! error TS7052: Element implicitly has an 'any' type because type '{ set: (key: string) => string; get: (key: string) => string; }' has no index signature. Did you mean to call 'set' ?
46+
3747

tests/baselines/reference/noImplicitAnyStringIndexerOnObject.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,43 @@
22
var a = {}["hello"];
33
var b: string = { '': 'foo' }[''];
44

5-
// Should give suggestion 'c.get'
65
var c = {
76
get: (key: string) => 'foobar'
87
};
98
c['hello'];
9+
const foo = c['hello'];
1010

11-
// Should give suggestion 'd.set'
1211
var d = {
1312
set: (key: string) => 'foobar'
1413
};
15-
d['hello'];
14+
const bar = d['hello'];
1615

17-
// Should give suggestion 'e.get or e.set'
1816
var e = {
1917
set: (key: string) => 'foobar',
2018
get: (key: string) => 'foobar'
2119
};
22-
e['hello'];
20+
e['hello'] = 'modified';
21+
e['hello'] += 1;
22+
e['hello'] ++;
23+
2324

2425

2526
//// [noImplicitAnyStringIndexerOnObject.js]
2627
var a = {}["hello"];
2728
var b = { '': 'foo' }[''];
28-
// Should give suggestion 'c.get'
2929
var c = {
3030
get: function (key) { return 'foobar'; }
3131
};
3232
c['hello'];
33-
// Should give suggestion 'd.set'
33+
var foo = c['hello'];
3434
var d = {
3535
set: function (key) { return 'foobar'; }
3636
};
37-
d['hello'];
38-
// Should give suggestion 'e.get or e.set'
37+
var bar = d['hello'];
3938
var e = {
4039
set: function (key) { return 'foobar'; },
4140
get: function (key) { return 'foobar'; }
4241
};
43-
e['hello'];
42+
e['hello'] = 'modified';
43+
e['hello'] += 1;
44+
e['hello']++;

tests/baselines/reference/noImplicitAnyStringIndexerOnObject.symbols

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,52 @@ var b: string = { '': 'foo' }[''];
77
>'' : Symbol('', Decl(noImplicitAnyStringIndexerOnObject.ts, 1, 17))
88
>'' : Symbol('', Decl(noImplicitAnyStringIndexerOnObject.ts, 1, 17))
99

10-
// Should give suggestion 'c.get'
1110
var c = {
12-
>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 4, 3))
11+
>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 3))
1312

1413
get: (key: string) => 'foobar'
15-
>get : Symbol(get, Decl(noImplicitAnyStringIndexerOnObject.ts, 4, 9))
16-
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 5, 8))
14+
>get : Symbol(get, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 9))
15+
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 4, 8))
1716

1817
};
1918
c['hello'];
20-
>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 4, 3))
19+
>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 3))
20+
21+
const foo = c['hello'];
22+
>foo : Symbol(foo, Decl(noImplicitAnyStringIndexerOnObject.ts, 7, 5))
23+
>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 3))
2124

22-
// Should give suggestion 'd.set'
2325
var d = {
24-
>d : Symbol(d, Decl(noImplicitAnyStringIndexerOnObject.ts, 10, 3))
26+
>d : Symbol(d, Decl(noImplicitAnyStringIndexerOnObject.ts, 9, 3))
2527

2628
set: (key: string) => 'foobar'
27-
>set : Symbol(set, Decl(noImplicitAnyStringIndexerOnObject.ts, 10, 9))
28-
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 11, 8))
29+
>set : Symbol(set, Decl(noImplicitAnyStringIndexerOnObject.ts, 9, 9))
30+
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 10, 8))
2931

3032
};
31-
d['hello'];
32-
>d : Symbol(d, Decl(noImplicitAnyStringIndexerOnObject.ts, 10, 3))
33+
const bar = d['hello'];
34+
>bar : Symbol(bar, Decl(noImplicitAnyStringIndexerOnObject.ts, 12, 5))
35+
>d : Symbol(d, Decl(noImplicitAnyStringIndexerOnObject.ts, 9, 3))
3336

34-
// Should give suggestion 'e.get or e.set'
3537
var e = {
36-
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 16, 3))
38+
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3))
3739

3840
set: (key: string) => 'foobar',
39-
>set : Symbol(set, Decl(noImplicitAnyStringIndexerOnObject.ts, 16, 9))
40-
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 17, 8))
41+
>set : Symbol(set, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 9))
42+
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 15, 8))
4143

4244
get: (key: string) => 'foobar'
43-
>get : Symbol(get, Decl(noImplicitAnyStringIndexerOnObject.ts, 17, 33))
44-
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 18, 8))
45+
>get : Symbol(get, Decl(noImplicitAnyStringIndexerOnObject.ts, 15, 33))
46+
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 16, 8))
4547

4648
};
47-
e['hello'];
48-
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 16, 3))
49+
e['hello'] = 'modified';
50+
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3))
51+
52+
e['hello'] += 1;
53+
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3))
54+
55+
e['hello'] ++;
56+
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3))
57+
4958

tests/baselines/reference/noImplicitAnyStringIndexerOnObject.types

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var b: string = { '': 'foo' }[''];
1313
>'foo' : "foo"
1414
>'' : ""
1515

16-
// Should give suggestion 'c.get'
1716
var c = {
1817
>c : { get: (key: string) => string; }
1918
>{ get: (key: string) => 'foobar'} : { get: (key: string) => string; }
@@ -30,7 +29,12 @@ c['hello'];
3029
>c : { get: (key: string) => string; }
3130
>'hello' : "hello"
3231

33-
// Should give suggestion 'd.set'
32+
const foo = c['hello'];
33+
>foo : any
34+
>c['hello'] : any
35+
>c : { get: (key: string) => string; }
36+
>'hello' : "hello"
37+
3438
var d = {
3539
>d : { set: (key: string) => string; }
3640
>{ set: (key: string) => 'foobar'} : { set: (key: string) => string; }
@@ -42,12 +46,12 @@ var d = {
4246
>'foobar' : "foobar"
4347

4448
};
45-
d['hello'];
49+
const bar = d['hello'];
50+
>bar : any
4651
>d['hello'] : any
4752
>d : { set: (key: string) => string; }
4853
>'hello' : "hello"
4954

50-
// Should give suggestion 'e.get or e.set'
5155
var e = {
5256
>e : { set: (key: string) => string; get: (key: string) => string; }
5357
>{ set: (key: string) => 'foobar', get: (key: string) => 'foobar'} : { set: (key: string) => string; get: (key: string) => string; }
@@ -65,8 +69,24 @@ var e = {
6569
>'foobar' : "foobar"
6670

6771
};
68-
e['hello'];
72+
e['hello'] = 'modified';
73+
>e['hello'] = 'modified' : "modified"
6974
>e['hello'] : any
7075
>e : { set: (key: string) => string; get: (key: string) => string; }
7176
>'hello' : "hello"
77+
>'modified' : "modified"
78+
79+
e['hello'] += 1;
80+
>e['hello'] += 1 : any
81+
>e['hello'] : any
82+
>e : { set: (key: string) => string; get: (key: string) => string; }
83+
>'hello' : "hello"
84+
>1 : 1
85+
86+
e['hello'] ++;
87+
>e['hello'] ++ : number
88+
>e['hello'] : any
89+
>e : { set: (key: string) => string; get: (key: string) => string; }
90+
>'hello' : "hello"
91+
7292

tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ var c = {
77
get: (key: string) => 'foobar'
88
};
99
c['hello'];
10+
const foo = c['hello'];
1011

1112
var d = {
1213
set: (key: string) => 'foobar'
1314
};
14-
d['hello'];
15+
const bar = d['hello'];
1516

1617
var e = {
1718
set: (key: string) => 'foobar',
1819
get: (key: string) => 'foobar'
1920
};
20-
e['hello'];
21+
e['hello'] = 'modified';
22+
e['hello'] += 1;
23+
e['hello'] ++;
24+

0 commit comments

Comments
 (0)