File: abstractPropertyNegative.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (112 lines) | stat: -rw-r--r-- 2,504 bytes parent folder | download | duplicates (5)
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); // error, not same type
>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
}