Skip to content

Commit

Permalink
refactor baselines
Browse files Browse the repository at this point in the history
  • Loading branch information
collin5 committed Apr 29, 2019
1 parent 7c5023a commit e330537
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 49 deletions.
@@ -1,37 +1,47 @@
tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts(1,9): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature.
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' ?
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' ?
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' ?
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' ?
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' ?
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.
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' ?
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' ?
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' ?


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

// Should give suggestion 'c.get'
var c = {
get: (key: string) => 'foobar'
};
c['hello'];
~~~~~~~~~~
!!! 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' ?
!!! error TS7052: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'get' ?
const foo = c['hello'];
~~~~~~~~~~
!!! error TS7052: Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'get' ?

// Should give suggestion 'd.set'
var d = {
set: (key: string) => 'foobar'
};
d['hello'];
~~~~~~~~~~
!!! 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' ?
const bar = d['hello'];
~~~~~~~~~~
!!! error TS7017: Element implicitly has an 'any' type because type '{ set: (key: string) => string; }' has no index signature.

// Should give suggestion 'e.get or e.set'
var e = {
set: (key: string) => 'foobar',
get: (key: string) => 'foobar'
};
e['hello'];
e['hello'] = 'modified';
~~~~~~~~~~
!!! 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' ?
e['hello'] += 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' ?
!!! 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' ?
e['hello'] ++;
~~~~~~~~~~
!!! 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' ?


21 changes: 11 additions & 10 deletions tests/baselines/reference/noImplicitAnyStringIndexerOnObject.js
Expand Up @@ -2,42 +2,43 @@
var a = {}["hello"];
var b: string = { '': 'foo' }[''];

// Should give suggestion 'c.get'
var c = {
get: (key: string) => 'foobar'
};
c['hello'];
const foo = c['hello'];

// Should give suggestion 'd.set'
var d = {
set: (key: string) => 'foobar'
};
d['hello'];
const bar = d['hello'];

// Should give suggestion 'e.get or e.set'
var e = {
set: (key: string) => 'foobar',
get: (key: string) => 'foobar'
};
e['hello'];
e['hello'] = 'modified';
e['hello'] += 1;
e['hello'] ++;



//// [noImplicitAnyStringIndexerOnObject.js]
var a = {}["hello"];
var b = { '': 'foo' }[''];
// Should give suggestion 'c.get'
var c = {
get: function (key) { return 'foobar'; }
};
c['hello'];
// Should give suggestion 'd.set'
var foo = c['hello'];
var d = {
set: function (key) { return 'foobar'; }
};
d['hello'];
// Should give suggestion 'e.get or e.set'
var bar = d['hello'];
var e = {
set: function (key) { return 'foobar'; },
get: function (key) { return 'foobar'; }
};
e['hello'];
e['hello'] = 'modified';
e['hello'] += 1;
e['hello']++;
Expand Up @@ -7,43 +7,52 @@ var b: string = { '': 'foo' }[''];
>'' : Symbol('', Decl(noImplicitAnyStringIndexerOnObject.ts, 1, 17))
>'' : Symbol('', Decl(noImplicitAnyStringIndexerOnObject.ts, 1, 17))

// Should give suggestion 'c.get'
var c = {
>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 4, 3))
>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 3))

get: (key: string) => 'foobar'
>get : Symbol(get, Decl(noImplicitAnyStringIndexerOnObject.ts, 4, 9))
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 5, 8))
>get : Symbol(get, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 9))
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 4, 8))

};
c['hello'];
>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 4, 3))
>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 3))

const foo = c['hello'];
>foo : Symbol(foo, Decl(noImplicitAnyStringIndexerOnObject.ts, 7, 5))
>c : Symbol(c, Decl(noImplicitAnyStringIndexerOnObject.ts, 3, 3))

// Should give suggestion 'd.set'
var d = {
>d : Symbol(d, Decl(noImplicitAnyStringIndexerOnObject.ts, 10, 3))
>d : Symbol(d, Decl(noImplicitAnyStringIndexerOnObject.ts, 9, 3))

set: (key: string) => 'foobar'
>set : Symbol(set, Decl(noImplicitAnyStringIndexerOnObject.ts, 10, 9))
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 11, 8))
>set : Symbol(set, Decl(noImplicitAnyStringIndexerOnObject.ts, 9, 9))
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 10, 8))

};
d['hello'];
>d : Symbol(d, Decl(noImplicitAnyStringIndexerOnObject.ts, 10, 3))
const bar = d['hello'];
>bar : Symbol(bar, Decl(noImplicitAnyStringIndexerOnObject.ts, 12, 5))
>d : Symbol(d, Decl(noImplicitAnyStringIndexerOnObject.ts, 9, 3))

// Should give suggestion 'e.get or e.set'
var e = {
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 16, 3))
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3))

set: (key: string) => 'foobar',
>set : Symbol(set, Decl(noImplicitAnyStringIndexerOnObject.ts, 16, 9))
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 17, 8))
>set : Symbol(set, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 9))
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 15, 8))

get: (key: string) => 'foobar'
>get : Symbol(get, Decl(noImplicitAnyStringIndexerOnObject.ts, 17, 33))
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 18, 8))
>get : Symbol(get, Decl(noImplicitAnyStringIndexerOnObject.ts, 15, 33))
>key : Symbol(key, Decl(noImplicitAnyStringIndexerOnObject.ts, 16, 8))

};
e['hello'];
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 16, 3))
e['hello'] = 'modified';
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3))

e['hello'] += 1;
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3))

e['hello'] ++;
>e : Symbol(e, Decl(noImplicitAnyStringIndexerOnObject.ts, 14, 3))


30 changes: 25 additions & 5 deletions tests/baselines/reference/noImplicitAnyStringIndexerOnObject.types
Expand Up @@ -13,7 +13,6 @@ var b: string = { '': 'foo' }[''];
>'foo' : "foo"
>'' : ""

// Should give suggestion 'c.get'
var c = {
>c : { get: (key: string) => string; }
>{ get: (key: string) => 'foobar'} : { get: (key: string) => string; }
Expand All @@ -30,7 +29,12 @@ c['hello'];
>c : { get: (key: string) => string; }
>'hello' : "hello"

// Should give suggestion 'd.set'
const foo = c['hello'];
>foo : any
>c['hello'] : any
>c : { get: (key: string) => string; }
>'hello' : "hello"

var d = {
>d : { set: (key: string) => string; }
>{ set: (key: string) => 'foobar'} : { set: (key: string) => string; }
Expand All @@ -42,12 +46,12 @@ var d = {
>'foobar' : "foobar"

};
d['hello'];
const bar = d['hello'];
>bar : any
>d['hello'] : any
>d : { set: (key: string) => string; }
>'hello' : "hello"

// Should give suggestion 'e.get or e.set'
var e = {
>e : { set: (key: string) => string; get: (key: string) => string; }
>{ set: (key: string) => 'foobar', get: (key: string) => 'foobar'} : { set: (key: string) => string; get: (key: string) => string; }
Expand All @@ -65,8 +69,24 @@ var e = {
>'foobar' : "foobar"

};
e['hello'];
e['hello'] = 'modified';
>e['hello'] = 'modified' : "modified"
>e['hello'] : any
>e : { set: (key: string) => string; get: (key: string) => string; }
>'hello' : "hello"
>'modified' : "modified"

e['hello'] += 1;
>e['hello'] += 1 : any
>e['hello'] : any
>e : { set: (key: string) => string; get: (key: string) => string; }
>'hello' : "hello"
>1 : 1

e['hello'] ++;
>e['hello'] ++ : number
>e['hello'] : any
>e : { set: (key: string) => string; get: (key: string) => string; }
>'hello' : "hello"


8 changes: 6 additions & 2 deletions tests/cases/compiler/noImplicitAnyStringIndexerOnObject.ts
Expand Up @@ -7,14 +7,18 @@ var c = {
get: (key: string) => 'foobar'
};
c['hello'];
const foo = c['hello'];

var d = {
set: (key: string) => 'foobar'
};
d['hello'];
const bar = d['hello'];

var e = {
set: (key: string) => 'foobar',
get: (key: string) => 'foobar'
};
e['hello'];
e['hello'] = 'modified';
e['hello'] += 1;
e['hello'] ++;

0 comments on commit e330537

Please sign in to comment.