File: objectTypeHidingMembersOfObjectAssignmentCompat2.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (73 lines) | stat: -rw-r--r-- 4,139 bytes parent folder | download | duplicates (3)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(7,1): error TS2322: Type 'I' is not assignable to type 'Object'.
  Types of property 'toString' are incompatible.
    Type '() => number' is not assignable to type '() => string'.
      Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(8,1): error TS2322: Type 'Object' is not assignable to type 'I'.
  The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
    Types of property 'toString' are incompatible.
      Type '() => string' is not assignable to type '() => number'.
        Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(14,1): error TS2322: Type 'C' is not assignable to type 'Object'.
  Types of property 'toString' are incompatible.
    Type '() => number' is not assignable to type '() => string'.
      Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(15,1): error TS2322: Type 'Object' is not assignable to type 'C'.
  The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
    Types of property 'toString' are incompatible.
      Type '() => string' is not assignable to type '() => number'.
        Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts(20,1): error TS2322: Type '{ toString: () => void; }' is not assignable to type 'Object'.
  Types of property 'toString' are incompatible.
    Type '() => void' is not assignable to type '() => string'.
      Type 'void' is not assignable to type 'string'.


==== tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts (5 errors) ====
    interface I {
        toString(): number;
    }
    
    var i: I;
    var o: Object;
    o = i; // error
    ~
!!! error TS2322: Type 'I' is not assignable to type 'Object'.
!!! error TS2322:   Types of property 'toString' are incompatible.
!!! error TS2322:     Type '() => number' is not assignable to type '() => string'.
!!! error TS2322:       Type 'number' is not assignable to type 'string'.
    i = o; // error
    ~
!!! error TS2322: Type 'Object' is not assignable to type 'I'.
!!! error TS2322:   The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
!!! error TS2322:     Types of property 'toString' are incompatible.
!!! error TS2322:       Type '() => string' is not assignable to type '() => number'.
!!! error TS2322:         Type 'string' is not assignable to type 'number'.
    
    class C {
        toString(): number { return 1; }
    }
    var c: C;
    o = c; // error
    ~
!!! error TS2322: Type 'C' is not assignable to type 'Object'.
!!! error TS2322:   Types of property 'toString' are incompatible.
!!! error TS2322:     Type '() => number' is not assignable to type '() => string'.
!!! error TS2322:       Type 'number' is not assignable to type 'string'.
    c = o; // error
    ~
!!! error TS2322: Type 'Object' is not assignable to type 'C'.
!!! error TS2322:   The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
!!! error TS2322:     Types of property 'toString' are incompatible.
!!! error TS2322:       Type '() => string' is not assignable to type '() => number'.
!!! error TS2322:         Type 'string' is not assignable to type 'number'.
    
    var a = {
        toString: () => { }
    }
    o = a; // error
    ~
!!! error TS2322: Type '{ toString: () => void; }' is not assignable to type 'Object'.
!!! error TS2322:   Types of property 'toString' are incompatible.
!!! error TS2322:     Type '() => void' is not assignable to type '() => string'.
!!! error TS2322:       Type 'void' is not assignable to type 'string'.
    a = o; // ok