|
| 1 | +tests/cases/compiler/abstractPropertyNegative.ts(10,18): error TS2380: 'get' and 'set' accessor must have the same type. |
| 2 | +tests/cases/compiler/abstractPropertyNegative.ts(11,18): error TS2380: 'get' and 'set' accessor must have the same type. |
| 3 | +tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'm' from class 'B'. |
| 4 | +tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'mismatch' from class 'B'. |
| 5 | +tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'prop' from class 'B'. |
| 6 | +tests/cases/compiler/abstractPropertyNegative.ts(13,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'readonlyProp' from class 'B'. |
| 7 | +tests/cases/compiler/abstractPropertyNegative.ts(15,5): error TS1244: Abstract methods can only appear within an abstract class. |
| 8 | +tests/cases/compiler/abstractPropertyNegative.ts(16,37): error TS1005: '{' expected. |
| 9 | +tests/cases/compiler/abstractPropertyNegative.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. |
| 10 | +tests/cases/compiler/abstractPropertyNegative.ts(24,7): error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'. |
| 11 | + Types of property 'num' are incompatible. |
| 12 | + Type 'string' is not assignable to type 'number'. |
| 13 | +tests/cases/compiler/abstractPropertyNegative.ts(30,7): error TS2415: Class 'WrongTypeAccessorImpl' incorrectly extends base class 'WrongTypeAccessor'. |
| 14 | + Types of property 'num' are incompatible. |
| 15 | + Type 'string' is not assignable to type 'number'. |
| 16 | +tests/cases/compiler/abstractPropertyNegative.ts(33,7): error TS2415: Class 'WrongTypeAccessorImpl2' incorrectly extends base class 'WrongTypeAccessor'. |
| 17 | + Types of property 'num' are incompatible. |
| 18 | + Type 'string' is not assignable to type 'number'. |
| 19 | +tests/cases/compiler/abstractPropertyNegative.ts(38,18): error TS2676: Accessors must both be abstract or non-abstract. |
| 20 | +tests/cases/compiler/abstractPropertyNegative.ts(39,9): error TS2676: Accessors must both be abstract or non-abstract. |
| 21 | +tests/cases/compiler/abstractPropertyNegative.ts(40,9): error TS2676: Accessors must both be abstract or non-abstract. |
| 22 | +tests/cases/compiler/abstractPropertyNegative.ts(41,18): error TS2676: Accessors must both be abstract or non-abstract. |
| 23 | + |
| 24 | + |
| 25 | +==== tests/cases/compiler/abstractPropertyNegative.ts (16 errors) ==== |
| 26 | + interface A { |
| 27 | + prop: string; |
| 28 | + m(): string; |
| 29 | + } |
| 30 | + abstract class B implements A { |
| 31 | + abstract prop: string; |
| 32 | + public abstract readonly ro: string; |
| 33 | + abstract get readonlyProp(): string; |
| 34 | + abstract m(): string; |
| 35 | + abstract get mismatch(): string; |
| 36 | + ~~~~~~~~ |
| 37 | +!!! error TS2380: 'get' and 'set' accessor must have the same type. |
| 38 | + abstract set mismatch(val: number); // error, not same type |
| 39 | + ~~~~~~~~ |
| 40 | +!!! error TS2380: 'get' and 'set' accessor must have the same type. |
| 41 | + } |
| 42 | + class C extends B { |
| 43 | + ~ |
| 44 | +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'm' from class 'B'. |
| 45 | + ~ |
| 46 | +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'mismatch' from class 'B'. |
| 47 | + ~ |
| 48 | +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'prop' from class 'B'. |
| 49 | + ~ |
| 50 | +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'readonlyProp' from class 'B'. |
| 51 | + readonly ro = "readonly please"; |
| 52 | + abstract notAllowed: string; |
| 53 | + ~~~~~~~~ |
| 54 | +!!! error TS1244: Abstract methods can only appear within an abstract class. |
| 55 | + get concreteWithNoBody(): string; |
| 56 | + ~ |
| 57 | +!!! error TS1005: '{' expected. |
| 58 | + } |
| 59 | + let c = new C(); |
| 60 | + c.ro = "error: lhs of assignment can't be readonly"; |
| 61 | + ~~~~ |
| 62 | +!!! error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. |
| 63 | + |
| 64 | + abstract class WrongTypeProperty { |
| 65 | + abstract num: number; |
| 66 | + } |
| 67 | + class WrongTypePropertyImpl extends WrongTypeProperty { |
| 68 | + ~~~~~~~~~~~~~~~~~~~~~ |
| 69 | +!!! error TS2415: Class 'WrongTypePropertyImpl' incorrectly extends base class 'WrongTypeProperty'. |
| 70 | +!!! error TS2415: Types of property 'num' are incompatible. |
| 71 | +!!! error TS2415: Type 'string' is not assignable to type 'number'. |
| 72 | + num = "nope, wrong"; |
| 73 | + } |
| 74 | + abstract class WrongTypeAccessor { |
| 75 | + abstract get num(): number; |
| 76 | + } |
| 77 | + class WrongTypeAccessorImpl extends WrongTypeAccessor { |
| 78 | + ~~~~~~~~~~~~~~~~~~~~~ |
| 79 | +!!! error TS2415: Class 'WrongTypeAccessorImpl' incorrectly extends base class 'WrongTypeAccessor'. |
| 80 | +!!! error TS2415: Types of property 'num' are incompatible. |
| 81 | +!!! error TS2415: Type 'string' is not assignable to type 'number'. |
| 82 | + get num() { return "nope, wrong"; } |
| 83 | + } |
| 84 | + class WrongTypeAccessorImpl2 extends WrongTypeAccessor { |
| 85 | + ~~~~~~~~~~~~~~~~~~~~~~ |
| 86 | +!!! error TS2415: Class 'WrongTypeAccessorImpl2' incorrectly extends base class 'WrongTypeAccessor'. |
| 87 | +!!! error TS2415: Types of property 'num' are incompatible. |
| 88 | +!!! error TS2415: Type 'string' is not assignable to type 'number'. |
| 89 | + num = "nope, wrong"; |
| 90 | + } |
| 91 | + |
| 92 | + abstract class AbstractAccessorMismatch { |
| 93 | + abstract get p1(): string; |
| 94 | + ~~ |
| 95 | +!!! error TS2676: Accessors must both be abstract or non-abstract. |
| 96 | + set p1(val: string) { }; |
| 97 | + ~~ |
| 98 | +!!! error TS2676: Accessors must both be abstract or non-abstract. |
| 99 | + get p2(): string { return "should work"; } |
| 100 | + ~~ |
| 101 | +!!! error TS2676: Accessors must both be abstract or non-abstract. |
| 102 | + abstract set p2(val: string); |
| 103 | + ~~ |
| 104 | +!!! error TS2676: Accessors must both be abstract or non-abstract. |
| 105 | + } |
| 106 | + |
0 commit comments