forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathabstractPropertyNegative.types
112 lines (89 loc) · 2.42 KB
/
abstractPropertyNegative.types
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
107
108
109
110
111
112
=== tests/cases/compiler/abstractPropertyNegative.ts ===
interface A {
prop: string;
>prop : string
m(): string;
>m : () => string
}
abstract class B implements A {
>B : B
abstract prop: string;
>prop : string
public abstract readonly ro: string;
>ro : string
abstract get readonlyProp(): string;
>readonlyProp : string
abstract m(): string;
>m : () => string
abstract get mismatch(): string;
>mismatch : string
abstract set mismatch(val: number);
>mismatch : string
>val : number
}
class C extends B {
>C : C
>B : B
readonly ro = "readonly please";
>ro : "readonly please"
>"readonly please" : "readonly please"
abstract notAllowed: string;
>notAllowed : string
get concreteWithNoBody(): string;
>concreteWithNoBody : string
}
let c = new C();
>c : C
>new C() : C
>C : typeof C
c.ro = "error: lhs of assignment can't be readonly";
>c.ro = "error: lhs of assignment can't be readonly" : "error: lhs of assignment can't be readonly"
>c.ro : any
>c : C
>ro : any
>"error: lhs of assignment can't be readonly" : "error: lhs of assignment can't be readonly"
abstract class WrongTypeProperty {
>WrongTypeProperty : WrongTypeProperty
abstract num: number;
>num : number
}
class WrongTypePropertyImpl extends WrongTypeProperty {
>WrongTypePropertyImpl : WrongTypePropertyImpl
>WrongTypeProperty : WrongTypeProperty
num = "nope, wrong";
>num : string
>"nope, wrong" : "nope, wrong"
}
abstract class WrongTypeAccessor {
>WrongTypeAccessor : WrongTypeAccessor
abstract get num(): number;
>num : number
}
class WrongTypeAccessorImpl extends WrongTypeAccessor {
>WrongTypeAccessorImpl : WrongTypeAccessorImpl
>WrongTypeAccessor : WrongTypeAccessor
get num() { return "nope, wrong"; }
>num : string
>"nope, wrong" : "nope, wrong"
}
class WrongTypeAccessorImpl2 extends WrongTypeAccessor {
>WrongTypeAccessorImpl2 : WrongTypeAccessorImpl2
>WrongTypeAccessor : WrongTypeAccessor
num = "nope, wrong";
>num : string
>"nope, wrong" : "nope, wrong"
}
abstract class AbstractAccessorMismatch {
>AbstractAccessorMismatch : AbstractAccessorMismatch
abstract get p1(): string;
>p1 : string
set p1(val: string) { };
>p1 : string
>val : string
get p2(): string { return "should work"; }
>p2 : string
>"should work" : "should work"
abstract set p2(val: string);
>p2 : string
>val : string
}