File: abstractPropertyNegative.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 203,960 kB
  • sloc: sh: 11; makefile: 5
file content (106 lines) | stat: -rw-r--r-- 6,037 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
tests/cases/compiler/abstractPropertyNegative.ts(10,18): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/abstractPropertyNegative.ts(11,18): error TS2380: 'get' and 'set' accessor must have the same type.
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'm' from class 'B'.
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'mismatch' from class 'B'.
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'prop' from class 'B'.
tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'readonlyProp' from class 'B'.
tests/cases/compiler/abstractPropertyNegative.ts(15,5): error TS1244: Abstract methods can only appear within an abstract class.
tests/cases/compiler/abstractPropertyNegative.ts(16,37): error TS1005: '{' expected.
tests/cases/compiler/abstractPropertyNegative.ts(19,3): error TS2540: Cannot assign to 'ro' because it is a constant or a read-only property.
tests/cases/compiler/abstractPropertyNegative.ts(24,7): error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'.
  Types of property 'num' are incompatible.
    Type 'string' is not assignable to type 'number'.
tests/cases/compiler/abstractPropertyNegative.ts(30,7): error TS2415: Class 'WrongTypeAccessorImpl' incorrectly extends base class 'WrongTypeAccessor'.
  Types of property 'num' are incompatible.
    Type 'string' is not assignable to type 'number'.
tests/cases/compiler/abstractPropertyNegative.ts(33,7): error TS2415: Class 'WrongTypeAccessorImpl2' incorrectly extends base class 'WrongTypeAccessor'.
  Types of property 'num' are incompatible.
    Type 'string' is not assignable to type 'number'.
tests/cases/compiler/abstractPropertyNegative.ts(38,18): error TS2676: Accessors must both be abstract or non-abstract.
tests/cases/compiler/abstractPropertyNegative.ts(39,9): error TS2676: Accessors must both be abstract or non-abstract.
tests/cases/compiler/abstractPropertyNegative.ts(40,9): error TS2676: Accessors must both be abstract or non-abstract.
tests/cases/compiler/abstractPropertyNegative.ts(41,18): error TS2676: Accessors must both be abstract or non-abstract.


==== tests/cases/compiler/abstractPropertyNegative.ts (16 errors) ====
    interface A {
        prop: string;
        m(): string;
    }
    abstract class B implements A {
        abstract prop: string;
        public abstract readonly ro: string;
        abstract get readonlyProp(): string;
        abstract m(): string;
        abstract get mismatch(): string;
                     ~~~~~~~~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
        abstract set mismatch(val: number); // error, not same type
                     ~~~~~~~~
!!! error TS2380: 'get' and 'set' accessor must have the same type.
    }
    class C extends B {
          ~
!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'm' from class 'B'.
          ~
!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'mismatch' from class 'B'.
          ~
!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'prop' from class 'B'.
          ~
!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'readonlyProp' from class 'B'.
        readonly ro = "readonly please";
        abstract notAllowed: string;
        ~~~~~~~~
!!! error TS1244: Abstract methods can only appear within an abstract class.
        get concreteWithNoBody(): string;
                                        ~
!!! error TS1005: '{' expected.
    }
    let c = new C();
    c.ro = "error: lhs of assignment can't be readonly";
      ~~
!!! error TS2540: Cannot assign to 'ro' because it is a constant or a read-only property.
    
    abstract class WrongTypeProperty {
        abstract num: number;
    }
    class WrongTypePropertyImpl extends WrongTypeProperty {
          ~~~~~~~~~~~~~~~~~~~~~
!!! error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'.
!!! error TS2415:   Types of property 'num' are incompatible.
!!! error TS2415:     Type 'string' is not assignable to type 'number'.
        num = "nope, wrong";
    }
    abstract class WrongTypeAccessor {
        abstract get num(): number;
    }
    class WrongTypeAccessorImpl extends WrongTypeAccessor {
          ~~~~~~~~~~~~~~~~~~~~~
!!! error TS2415: Class 'WrongTypeAccessorImpl' incorrectly extends base class 'WrongTypeAccessor'.
!!! error TS2415:   Types of property 'num' are incompatible.
!!! error TS2415:     Type 'string' is not assignable to type 'number'.
        get num() { return "nope, wrong"; }
    }
    class WrongTypeAccessorImpl2 extends WrongTypeAccessor {
          ~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2415: Class 'WrongTypeAccessorImpl2' incorrectly extends base class 'WrongTypeAccessor'.
!!! error TS2415:   Types of property 'num' are incompatible.
!!! error TS2415:     Type 'string' is not assignable to type 'number'.
        num = "nope, wrong";
    }
    
    abstract class AbstractAccessorMismatch {
        abstract get p1(): string;
                     ~~
!!! error TS2676: Accessors must both be abstract or non-abstract.
        set p1(val: string) { };
            ~~
!!! error TS2676: Accessors must both be abstract or non-abstract.
        get p2(): string { return "should work"; }
            ~~
!!! error TS2676: Accessors must both be abstract or non-abstract.
        abstract set p2(val: string);
                     ~~
!!! error TS2676: Accessors must both be abstract or non-abstract.
    }