File: objectTypeWithStringIndexerHidingObjectIndexer.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (55 lines) | stat: -rw-r--r-- 3,275 bytes parent folder | download | duplicates (2)
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
50
51
52
53
54
55
tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'constructor' of type 'Function' is not assignable to string index type 'Object'.
tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'hasOwnProperty' of type '(v: string) => boolean' is not assignable to string index type 'Object'.
tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to string index type 'Object'.
tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'propertyIsEnumerable' of type '(v: string) => boolean' is not assignable to string index type 'Object'.
tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to string index type 'Object'.
tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'toString' of type '() => string' is not assignable to string index type 'Object'.
tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts(5,5): error TS2411: Property 'valueOf' of type '() => Object' is not assignable to string index type 'Object'.


==== tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts (7 errors) ====
    // object types can define string indexers that are more specific than the default 'any' that would be returned
    // no errors expected below 
    
    interface Object {
        [x: string]: Object;
        ~~~~~~~~~~~~~~~~~~~~
!!! error TS2411: Property 'constructor' of type 'Function' is not assignable to string index type 'Object'.
        ~~~~~~~~~~~~~~~~~~~~
!!! error TS2411: Property 'hasOwnProperty' of type '(v: string) => boolean' is not assignable to string index type 'Object'.
        ~~~~~~~~~~~~~~~~~~~~
!!! error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to string index type 'Object'.
        ~~~~~~~~~~~~~~~~~~~~
!!! error TS2411: Property 'propertyIsEnumerable' of type '(v: string) => boolean' is not assignable to string index type 'Object'.
        ~~~~~~~~~~~~~~~~~~~~
!!! error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to string index type 'Object'.
        ~~~~~~~~~~~~~~~~~~~~
!!! error TS2411: Property 'toString' of type '() => string' is not assignable to string index type 'Object'.
        ~~~~~~~~~~~~~~~~~~~~
!!! error TS2411: Property 'valueOf' of type '() => Object' is not assignable to string index type 'Object'.
    }
    var o = {};
    var r = o['']; // should be Object
    
    class C {
        foo: string;
        [x: string]: string;
    }
    var c: C;
    var r2: string = c[''];
    
    interface I {
        bar: string;
        [x: string]: string;
    }
    var i: I;
    var r3: string = i[''];
    
    var o2: {
        baz: string;
        [x: string]: string;
    }
    var r4: string = o2[''];