File: objectTypeWithStringIndexerHidingObjectIndexer.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 459,116 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (41 lines) | stat: -rw-r--r-- 1,744 bytes parent folder | download
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
lib.es5.d.ts(--,--): error TS2411: Property 'constructor' of type 'Function' is not assignable to 'string' index type 'Object'.
lib.es5.d.ts(--,--): error TS2411: Property 'toString' of type '() => string' is not assignable to 'string' index type 'Object'.
lib.es5.d.ts(--,--): error TS2411: Property 'toLocaleString' of type '() => string' is not assignable to 'string' index type 'Object'.
lib.es5.d.ts(--,--): error TS2411: Property 'valueOf' of type '() => Object' is not assignable to 'string' index type 'Object'.
lib.es5.d.ts(--,--): error TS2411: Property 'hasOwnProperty' of type '(v: PropertyKey) => boolean' is not assignable to 'string' index type 'Object'.
lib.es5.d.ts(--,--): error TS2411: Property 'isPrototypeOf' of type '(v: Object) => boolean' is not assignable to 'string' index type 'Object'.
lib.es5.d.ts(--,--): error TS2411: Property 'propertyIsEnumerable' of type '(v: PropertyKey) => boolean' is not assignable to 'string' index type 'Object'.


==== tests/cases/conformance/types/members/objectTypeWithStringIndexerHidingObjectIndexer.ts (0 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;
    }
    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[''];