File: derivedClassWithoutExplicitConstructor3.types

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 (152 lines) | stat: -rw-r--r-- 2,316 bytes parent folder | download
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
=== tests/cases/conformance/classes/constructorDeclarations/automaticConstructors/derivedClassWithoutExplicitConstructor3.ts ===
// automatic constructors with a class hieararchy of depth > 2

class Base {
>Base : Base

    a = 1;
>a : number
>1 : 1

    constructor(x: number) { this.a = x; }
>x : number
>this.a = x : number
>this.a : number
>this : this
>a : number
>x : number
}

class Derived extends Base {
>Derived : Derived
>Base : Base

    b = '';
>b : string
>'' : ""

    constructor(y: string, z: string) {
>y : string
>z : string

        super(2);
>super(2) : void
>super : typeof Base
>2 : 2

        this.b = y;
>this.b = y : string
>this.b : string
>this : this
>b : string
>y : string
    }
}

class Derived2 extends Derived {
>Derived2 : Derived2
>Derived : Derived

    x = 1
>x : number
>1 : 1

    y = 'hello';
>y : string
>'hello' : "hello"
}

var r = new Derived(); // error
>r : any
>new Derived() : any
>Derived : typeof Derived

var r2 = new Derived2(1); // error
>r2 : any
>new Derived2(1) : any
>Derived2 : typeof Derived2
>1 : 1

var r3 = new Derived('', '');
>r3 : Derived
>new Derived('', '') : Derived
>Derived : typeof Derived
>'' : ""
>'' : ""

class Base2<T> {
>Base2 : Base2<T>

    a: T;
>a : T

    constructor(x: T) { this.a = x; }
>x : T
>this.a = x : T
>this.a : T
>this : this
>a : T
>x : T
}

class D<T> extends Base {
>D : D<T>
>Base : Base

    b: T = null;
>b : T
>null : null

    constructor(y: T, z: T) {
>y : T
>z : T

        super(2);
>super(2) : void
>super : typeof Base
>2 : 2

        this.b = y;
>this.b = y : T
>this.b : T
>this : this
>b : T
>y : T
    }
}


class D2<T extends Date> extends D<T> {
>D2 : D2<T>
>D : D<T>

    x = 2
>x : number
>2 : 2

    y: T = null;
>y : T
>null : null
}

var d = new D2(); // error
>d : any
>new D2() : any
>D2 : typeof D2

var d2 = new D2(new Date()); // error
>d2 : any
>new D2(new Date()) : any
>D2 : typeof D2
>new Date() : Date
>Date : DateConstructor

var d3 = new D2(new Date(), new Date()); // ok
>d3 : D2<Date>
>new D2(new Date(), new Date()) : D2<Date>
>D2 : typeof D2
>new Date() : Date
>Date : DateConstructor
>new Date() : Date
>Date : DateConstructor