Skip to content

Commit 004dbf4

Browse files
committed
Accept new baselines
1 parent 56b1dcd commit 004dbf4

9 files changed

+1990
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
//// [mixinClassesAnnotated.ts]
2+
3+
type Constructor<T> = new(...args: any[]) => T;
4+
5+
class Base {
6+
constructor(public x: number, public y: number) {}
7+
}
8+
9+
class Derived extends Base {
10+
constructor(x: number, y: number, public z: number) {
11+
super(x, y);
12+
}
13+
}
14+
15+
interface Printable {
16+
print(): void;
17+
}
18+
19+
const Printable = <T extends Constructor<Base>>(superClass: T): Constructor<Printable> & { message: string } & T =>
20+
class extends superClass {
21+
static message = "hello";
22+
print() {
23+
const output = this.x + "," + this.y;
24+
}
25+
}
26+
27+
interface Tagged {
28+
_tag: string;
29+
}
30+
31+
function Tagged<T extends Constructor<{}>>(superClass: T): Constructor<Tagged> & T {
32+
class C extends superClass {
33+
_tag: string;
34+
constructor(...args: any[]) {
35+
super(...args);
36+
this._tag = "hello";
37+
}
38+
}
39+
return C;
40+
}
41+
42+
const Thing1 = Tagged(Derived);
43+
const Thing2 = Tagged(Printable(Derived));
44+
Thing2.message;
45+
46+
function f1() {
47+
const thing = new Thing1(1, 2, 3);
48+
thing.x;
49+
thing._tag;
50+
}
51+
52+
function f2() {
53+
const thing = new Thing2(1, 2, 3);
54+
thing.x;
55+
thing._tag;
56+
thing.print();
57+
}
58+
59+
class Thing3 extends Thing2 {
60+
constructor(tag: string) {
61+
super(10, 20, 30);
62+
this._tag = tag;
63+
}
64+
test() {
65+
this.print();
66+
}
67+
}
68+
69+
70+
//// [mixinClassesAnnotated.js]
71+
var __extends = (this && this.__extends) || (function () {
72+
var extendStatics = Object.setPrototypeOf ||
73+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
74+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
75+
return function (d, b) {
76+
extendStatics(d, b);
77+
function __() { this.constructor = d; }
78+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
79+
};
80+
})();
81+
var Base = (function () {
82+
function Base(x, y) {
83+
this.x = x;
84+
this.y = y;
85+
}
86+
return Base;
87+
}());
88+
var Derived = (function (_super) {
89+
__extends(Derived, _super);
90+
function Derived(x, y, z) {
91+
var _this = _super.call(this, x, y) || this;
92+
_this.z = z;
93+
return _this;
94+
}
95+
return Derived;
96+
}(Base));
97+
var Printable = function (superClass) { return _a = (function (_super) {
98+
__extends(class_1, _super);
99+
function class_1() {
100+
return _super !== null && _super.apply(this, arguments) || this;
101+
}
102+
class_1.prototype.print = function () {
103+
var output = this.x + "," + this.y;
104+
};
105+
return class_1;
106+
}(superClass)),
107+
_a.message = "hello",
108+
_a; var _a; };
109+
function Tagged(superClass) {
110+
var C = (function (_super) {
111+
__extends(C, _super);
112+
function C() {
113+
var args = [];
114+
for (var _i = 0; _i < arguments.length; _i++) {
115+
args[_i] = arguments[_i];
116+
}
117+
var _this = _super.apply(this, args) || this;
118+
_this._tag = "hello";
119+
return _this;
120+
}
121+
return C;
122+
}(superClass));
123+
return C;
124+
}
125+
var Thing1 = Tagged(Derived);
126+
var Thing2 = Tagged(Printable(Derived));
127+
Thing2.message;
128+
function f1() {
129+
var thing = new Thing1(1, 2, 3);
130+
thing.x;
131+
thing._tag;
132+
}
133+
function f2() {
134+
var thing = new Thing2(1, 2, 3);
135+
thing.x;
136+
thing._tag;
137+
thing.print();
138+
}
139+
var Thing3 = (function (_super) {
140+
__extends(Thing3, _super);
141+
function Thing3(tag) {
142+
var _this = _super.call(this, 10, 20, 30) || this;
143+
_this._tag = tag;
144+
return _this;
145+
}
146+
Thing3.prototype.test = function () {
147+
this.print();
148+
};
149+
return Thing3;
150+
}(Thing2));
151+
152+
153+
//// [mixinClassesAnnotated.d.ts]
154+
declare type Constructor<T> = new (...args: any[]) => T;
155+
declare class Base {
156+
x: number;
157+
y: number;
158+
constructor(x: number, y: number);
159+
}
160+
declare class Derived extends Base {
161+
z: number;
162+
constructor(x: number, y: number, z: number);
163+
}
164+
interface Printable {
165+
print(): void;
166+
}
167+
declare const Printable: <T extends Constructor<Base>>(superClass: T) => Constructor<Printable> & {
168+
message: string;
169+
} & T;
170+
interface Tagged {
171+
_tag: string;
172+
}
173+
declare function Tagged<T extends Constructor<{}>>(superClass: T): Constructor<Tagged> & T;
174+
declare const Thing1: Constructor<Tagged> & typeof Derived;
175+
declare const Thing2: Constructor<Tagged> & Constructor<Printable> & {
176+
message: string;
177+
} & typeof Derived;
178+
declare function f1(): void;
179+
declare function f2(): void;
180+
declare class Thing3 extends Thing2 {
181+
constructor(tag: string);
182+
test(): void;
183+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
=== tests/cases/conformance/classes/mixinClassesAnnotated.ts ===
2+
3+
type Constructor<T> = new(...args: any[]) => T;
4+
>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0))
5+
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 1, 17))
6+
>args : Symbol(args, Decl(mixinClassesAnnotated.ts, 1, 26))
7+
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 1, 17))
8+
9+
class Base {
10+
>Base : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47))
11+
12+
constructor(public x: number, public y: number) {}
13+
>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
14+
>y : Symbol(Base.y, Decl(mixinClassesAnnotated.ts, 4, 33))
15+
}
16+
17+
class Derived extends Base {
18+
>Derived : Symbol(Derived, Decl(mixinClassesAnnotated.ts, 5, 1))
19+
>Base : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47))
20+
21+
constructor(x: number, y: number, public z: number) {
22+
>x : Symbol(x, Decl(mixinClassesAnnotated.ts, 8, 16))
23+
>y : Symbol(y, Decl(mixinClassesAnnotated.ts, 8, 26))
24+
>z : Symbol(Derived.z, Decl(mixinClassesAnnotated.ts, 8, 37))
25+
26+
super(x, y);
27+
>super : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47))
28+
>x : Symbol(x, Decl(mixinClassesAnnotated.ts, 8, 16))
29+
>y : Symbol(y, Decl(mixinClassesAnnotated.ts, 8, 26))
30+
}
31+
}
32+
33+
interface Printable {
34+
>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5))
35+
36+
print(): void;
37+
>print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21))
38+
}
39+
40+
const Printable = <T extends Constructor<Base>>(superClass: T): Constructor<Printable> & { message: string } & T =>
41+
>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5))
42+
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 17, 19))
43+
>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0))
44+
>Base : Symbol(Base, Decl(mixinClassesAnnotated.ts, 1, 47))
45+
>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 17, 48))
46+
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 17, 19))
47+
>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0))
48+
>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5))
49+
>message : Symbol(message, Decl(mixinClassesAnnotated.ts, 17, 90))
50+
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 17, 19))
51+
52+
class extends superClass {
53+
>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 17, 48))
54+
55+
static message = "hello";
56+
>message : Symbol((Anonymous class).message, Decl(mixinClassesAnnotated.ts, 18, 30))
57+
58+
print() {
59+
>print : Symbol((Anonymous class).print, Decl(mixinClassesAnnotated.ts, 19, 33))
60+
61+
const output = this.x + "," + this.y;
62+
>output : Symbol(output, Decl(mixinClassesAnnotated.ts, 21, 17))
63+
>this.x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
64+
>this : Symbol((Anonymous class), Decl(mixinClassesAnnotated.ts, 17, 115))
65+
>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
66+
>this.y : Symbol(Base.y, Decl(mixinClassesAnnotated.ts, 4, 33))
67+
>this : Symbol((Anonymous class), Decl(mixinClassesAnnotated.ts, 17, 115))
68+
>y : Symbol(Base.y, Decl(mixinClassesAnnotated.ts, 4, 33))
69+
}
70+
}
71+
72+
interface Tagged {
73+
>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1))
74+
75+
_tag: string;
76+
>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
77+
}
78+
79+
function Tagged<T extends Constructor<{}>>(superClass: T): Constructor<Tagged> & T {
80+
>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1))
81+
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16))
82+
>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0))
83+
>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 29, 43))
84+
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16))
85+
>Constructor : Symbol(Constructor, Decl(mixinClassesAnnotated.ts, 0, 0))
86+
>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1))
87+
>T : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16))
88+
89+
class C extends superClass {
90+
>C : Symbol(C, Decl(mixinClassesAnnotated.ts, 29, 84))
91+
>superClass : Symbol(superClass, Decl(mixinClassesAnnotated.ts, 29, 43))
92+
93+
_tag: string;
94+
>_tag : Symbol(C._tag, Decl(mixinClassesAnnotated.ts, 30, 32))
95+
96+
constructor(...args: any[]) {
97+
>args : Symbol(args, Decl(mixinClassesAnnotated.ts, 32, 20))
98+
99+
super(...args);
100+
>super : Symbol(T, Decl(mixinClassesAnnotated.ts, 29, 16))
101+
>args : Symbol(args, Decl(mixinClassesAnnotated.ts, 32, 20))
102+
103+
this._tag = "hello";
104+
>this._tag : Symbol(C._tag, Decl(mixinClassesAnnotated.ts, 30, 32))
105+
>this : Symbol(C, Decl(mixinClassesAnnotated.ts, 29, 84))
106+
>_tag : Symbol(C._tag, Decl(mixinClassesAnnotated.ts, 30, 32))
107+
}
108+
}
109+
return C;
110+
>C : Symbol(C, Decl(mixinClassesAnnotated.ts, 29, 84))
111+
}
112+
113+
const Thing1 = Tagged(Derived);
114+
>Thing1 : Symbol(Thing1, Decl(mixinClassesAnnotated.ts, 40, 5))
115+
>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1))
116+
>Derived : Symbol(Derived, Decl(mixinClassesAnnotated.ts, 5, 1))
117+
118+
const Thing2 = Tagged(Printable(Derived));
119+
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5))
120+
>Tagged : Symbol(Tagged, Decl(mixinClassesAnnotated.ts, 23, 5), Decl(mixinClassesAnnotated.ts, 27, 1))
121+
>Printable : Symbol(Printable, Decl(mixinClassesAnnotated.ts, 11, 1), Decl(mixinClassesAnnotated.ts, 17, 5))
122+
>Derived : Symbol(Derived, Decl(mixinClassesAnnotated.ts, 5, 1))
123+
124+
Thing2.message;
125+
>Thing2.message : Symbol(message, Decl(mixinClassesAnnotated.ts, 17, 90))
126+
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5))
127+
>message : Symbol(message, Decl(mixinClassesAnnotated.ts, 17, 90))
128+
129+
function f1() {
130+
>f1 : Symbol(f1, Decl(mixinClassesAnnotated.ts, 42, 15))
131+
132+
const thing = new Thing1(1, 2, 3);
133+
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 45, 9))
134+
>Thing1 : Symbol(Thing1, Decl(mixinClassesAnnotated.ts, 40, 5))
135+
136+
thing.x;
137+
>thing.x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
138+
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 45, 9))
139+
>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
140+
141+
thing._tag;
142+
>thing._tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
143+
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 45, 9))
144+
>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
145+
}
146+
147+
function f2() {
148+
>f2 : Symbol(f2, Decl(mixinClassesAnnotated.ts, 48, 1))
149+
150+
const thing = new Thing2(1, 2, 3);
151+
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9))
152+
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5))
153+
154+
thing.x;
155+
>thing.x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
156+
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9))
157+
>x : Symbol(Base.x, Decl(mixinClassesAnnotated.ts, 4, 16))
158+
159+
thing._tag;
160+
>thing._tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
161+
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9))
162+
>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
163+
164+
thing.print();
165+
>thing.print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21))
166+
>thing : Symbol(thing, Decl(mixinClassesAnnotated.ts, 51, 9))
167+
>print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21))
168+
}
169+
170+
class Thing3 extends Thing2 {
171+
>Thing3 : Symbol(Thing3, Decl(mixinClassesAnnotated.ts, 55, 1))
172+
>Thing2 : Symbol(Thing2, Decl(mixinClassesAnnotated.ts, 41, 5))
173+
174+
constructor(tag: string) {
175+
>tag : Symbol(tag, Decl(mixinClassesAnnotated.ts, 58, 16))
176+
177+
super(10, 20, 30);
178+
this._tag = tag;
179+
>this._tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
180+
>this : Symbol(Thing3, Decl(mixinClassesAnnotated.ts, 55, 1))
181+
>_tag : Symbol(Tagged._tag, Decl(mixinClassesAnnotated.ts, 25, 18))
182+
>tag : Symbol(tag, Decl(mixinClassesAnnotated.ts, 58, 16))
183+
}
184+
test() {
185+
>test : Symbol(Thing3.test, Decl(mixinClassesAnnotated.ts, 61, 5))
186+
187+
this.print();
188+
>this.print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21))
189+
>this : Symbol(Thing3, Decl(mixinClassesAnnotated.ts, 55, 1))
190+
>print : Symbol(Printable.print, Decl(mixinClassesAnnotated.ts, 13, 21))
191+
}
192+
}
193+

0 commit comments

Comments
 (0)