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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
=== tests/cases/conformance/classes/mixinClassesAnnotated.ts ===
type Constructor<T> = new(...args: any[]) => T;
>Constructor : Constructor<T>
>args : any[]
class Base {
>Base : Base
constructor(public x: number, public y: number) {}
>x : number
>y : number
}
class Derived extends Base {
>Derived : Derived
>Base : Base
constructor(x: number, y: number, public z: number) {
>x : number
>y : number
>z : number
super(x, y);
>super(x, y) : void
>super : typeof Base
>x : number
>y : number
}
}
interface Printable {
print(): void;
>print : () => void
}
const Printable = <T extends Constructor<Base>>(superClass: T): Constructor<Printable> & { message: string } & T =>
>Printable : <T extends Constructor<Base>>(superClass: T) => Constructor<Printable> & { message: string; } & T
><T extends Constructor<Base>>(superClass: T): Constructor<Printable> & { message: string } & T => class extends superClass { static message = "hello"; print() { const output = this.x + "," + this.y; } } : <T extends Constructor<Base>>(superClass: T) => Constructor<Printable> & { message: string; } & T
>superClass : T
>message : string
class extends superClass {
>class extends superClass { static message = "hello"; print() { const output = this.x + "," + this.y; } } : { new (...args: any[]): (Anonymous class); prototype: Printable<any>.(Anonymous class); message: string; } & T
>superClass : Base
static message = "hello";
>message : string
>"hello" : "hello"
print() {
>print : () => void
const output = this.x + "," + this.y;
>output : string
>this.x + "," + this.y : string
>this.x + "," : string
>this.x : number
>this : this
>x : number
>"," : ","
>this.y : number
>this : this
>y : number
}
}
interface Tagged {
_tag: string;
>_tag : string
}
function Tagged<T extends Constructor<{}>>(superClass: T): Constructor<Tagged> & T {
>Tagged : <T extends Constructor<{}>>(superClass: T) => Constructor<Tagged> & T
>superClass : T
class C extends superClass {
>C : C
>superClass : {}
_tag: string;
>_tag : string
constructor(...args: any[]) {
>args : any[]
super(...args);
>super(...args) : void
>super : T
>...args : any
>args : any[]
this._tag = "hello";
>this._tag = "hello" : "hello"
>this._tag : string
>this : this
>_tag : string
>"hello" : "hello"
}
}
return C;
>C : { new (...args: any[]): C; prototype: Tagged<any>.C; } & T
}
const Thing1 = Tagged(Derived);
>Thing1 : Constructor<Tagged> & typeof Derived
>Tagged(Derived) : Constructor<Tagged> & typeof Derived
>Tagged : <T extends Constructor<{}>>(superClass: T) => Constructor<Tagged> & T
>Derived : typeof Derived
const Thing2 = Tagged(Printable(Derived));
>Thing2 : Constructor<Tagged> & Constructor<Printable> & { message: string; } & typeof Derived
>Tagged(Printable(Derived)) : Constructor<Tagged> & Constructor<Printable> & { message: string; } & typeof Derived
>Tagged : <T extends Constructor<{}>>(superClass: T) => Constructor<Tagged> & T
>Printable(Derived) : Constructor<Printable> & { message: string; } & typeof Derived
>Printable : <T extends Constructor<Base>>(superClass: T) => Constructor<Printable> & { message: string; } & T
>Derived : typeof Derived
Thing2.message;
>Thing2.message : string
>Thing2 : Constructor<Tagged> & Constructor<Printable> & { message: string; } & typeof Derived
>message : string
function f1() {
>f1 : () => void
const thing = new Thing1(1, 2, 3);
>thing : Tagged & Derived
>new Thing1(1, 2, 3) : Tagged & Derived
>Thing1 : Constructor<Tagged> & typeof Derived
>1 : 1
>2 : 2
>3 : 3
thing.x;
>thing.x : number
>thing : Tagged & Derived
>x : number
thing._tag;
>thing._tag : string
>thing : Tagged & Derived
>_tag : string
}
function f2() {
>f2 : () => void
const thing = new Thing2(1, 2, 3);
>thing : Tagged & Printable & Derived
>new Thing2(1, 2, 3) : Tagged & Printable & Derived
>Thing2 : Constructor<Tagged> & Constructor<Printable> & { message: string; } & typeof Derived
>1 : 1
>2 : 2
>3 : 3
thing.x;
>thing.x : number
>thing : Tagged & Printable & Derived
>x : number
thing._tag;
>thing._tag : string
>thing : Tagged & Printable & Derived
>_tag : string
thing.print();
>thing.print() : void
>thing.print : () => void
>thing : Tagged & Printable & Derived
>print : () => void
}
class Thing3 extends Thing2 {
>Thing3 : Thing3
>Thing2 : Tagged & Printable & Derived
constructor(tag: string) {
>tag : string
super(10, 20, 30);
>super(10, 20, 30) : void
>super : Constructor<Tagged> & Constructor<Printable> & { message: string; } & typeof Derived
>10 : 10
>20 : 20
>30 : 30
this._tag = tag;
>this._tag = tag : string
>this._tag : string
>this : this
>_tag : string
>tag : string
}
test() {
>test : () => void
this.print();
>this.print() : void
>this.print : () => void
>this : this
>print : () => void
}
}
|