Skip to content

Commit 186f525

Browse files
committed
Accepting new baselines
1 parent d575259 commit 186f525

10 files changed

Lines changed: 518 additions & 0 deletions
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
//// [classExtendingBuiltinType.ts]
2+
class C1 extends Object { }
3+
class C2 extends Function { }
4+
class C3 extends String { }
5+
class C4 extends Boolean { }
6+
class C5 extends Number { }
7+
class C6 extends Date { }
8+
class C7 extends RegExp { }
9+
class C8 extends Error { }
10+
class C9 extends Array { }
11+
class C10 extends Array<number> { }
12+
13+
14+
//// [classExtendingBuiltinType.js]
15+
var __extends = (this && this.__extends) || function (d, b) {
16+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
17+
function __() { this.constructor = d; }
18+
__.prototype = b.prototype;
19+
d.prototype = new __();
20+
};
21+
var C1 = (function (_super) {
22+
__extends(C1, _super);
23+
function C1() {
24+
_super.apply(this, arguments);
25+
}
26+
return C1;
27+
})(Object);
28+
var C2 = (function (_super) {
29+
__extends(C2, _super);
30+
function C2() {
31+
_super.apply(this, arguments);
32+
}
33+
return C2;
34+
})(Function);
35+
var C3 = (function (_super) {
36+
__extends(C3, _super);
37+
function C3() {
38+
_super.apply(this, arguments);
39+
}
40+
return C3;
41+
})(String);
42+
var C4 = (function (_super) {
43+
__extends(C4, _super);
44+
function C4() {
45+
_super.apply(this, arguments);
46+
}
47+
return C4;
48+
})(Boolean);
49+
var C5 = (function (_super) {
50+
__extends(C5, _super);
51+
function C5() {
52+
_super.apply(this, arguments);
53+
}
54+
return C5;
55+
})(Number);
56+
var C6 = (function (_super) {
57+
__extends(C6, _super);
58+
function C6() {
59+
_super.apply(this, arguments);
60+
}
61+
return C6;
62+
})(Date);
63+
var C7 = (function (_super) {
64+
__extends(C7, _super);
65+
function C7() {
66+
_super.apply(this, arguments);
67+
}
68+
return C7;
69+
})(RegExp);
70+
var C8 = (function (_super) {
71+
__extends(C8, _super);
72+
function C8() {
73+
_super.apply(this, arguments);
74+
}
75+
return C8;
76+
})(Error);
77+
var C9 = (function (_super) {
78+
__extends(C9, _super);
79+
function C9() {
80+
_super.apply(this, arguments);
81+
}
82+
return C9;
83+
})(Array);
84+
var C10 = (function (_super) {
85+
__extends(C10, _super);
86+
function C10() {
87+
_super.apply(this, arguments);
88+
}
89+
return C10;
90+
})(Array);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
=== tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts ===
2+
class C1 extends Object { }
3+
>C1 : Symbol(C1, Decl(classExtendingBuiltinType.ts, 0, 0))
4+
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
5+
6+
class C2 extends Function { }
7+
>C2 : Symbol(C2, Decl(classExtendingBuiltinType.ts, 0, 27))
8+
>Function : Symbol(Function, Decl(lib.d.ts, 223, 38), Decl(lib.d.ts, 269, 11))
9+
10+
class C3 extends String { }
11+
>C3 : Symbol(C3, Decl(classExtendingBuiltinType.ts, 1, 29))
12+
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11))
13+
14+
class C4 extends Boolean { }
15+
>C4 : Symbol(C4, Decl(classExtendingBuiltinType.ts, 2, 27))
16+
>Boolean : Symbol(Boolean, Decl(lib.d.ts, 443, 38), Decl(lib.d.ts, 456, 11))
17+
18+
class C5 extends Number { }
19+
>C5 : Symbol(C5, Decl(classExtendingBuiltinType.ts, 3, 28))
20+
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
21+
22+
class C6 extends Date { }
23+
>C6 : Symbol(C6, Decl(classExtendingBuiltinType.ts, 4, 27))
24+
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
25+
26+
class C7 extends RegExp { }
27+
>C7 : Symbol(C7, Decl(classExtendingBuiltinType.ts, 5, 25))
28+
>RegExp : Symbol(RegExp, Decl(lib.d.ts, 825, 1), Decl(lib.d.ts, 876, 11))
29+
30+
class C8 extends Error { }
31+
>C8 : Symbol(C8, Decl(classExtendingBuiltinType.ts, 6, 27))
32+
>Error : Symbol(Error, Decl(lib.d.ts, 876, 38), Decl(lib.d.ts, 889, 11))
33+
34+
class C9 extends Array { }
35+
>C9 : Symbol(C9, Decl(classExtendingBuiltinType.ts, 7, 26))
36+
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
37+
38+
class C10 extends Array<number> { }
39+
>C10 : Symbol(C10, Decl(classExtendingBuiltinType.ts, 8, 26))
40+
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
41+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
=== tests/cases/conformance/classes/classDeclarations/classExtendingBuiltinType.ts ===
2+
class C1 extends Object { }
3+
>C1 : C1
4+
>Object : ObjectConstructor
5+
6+
class C2 extends Function { }
7+
>C2 : C2
8+
>Function : FunctionConstructor
9+
10+
class C3 extends String { }
11+
>C3 : C3
12+
>String : StringConstructor
13+
14+
class C4 extends Boolean { }
15+
>C4 : C4
16+
>Boolean : BooleanConstructor
17+
18+
class C5 extends Number { }
19+
>C5 : C5
20+
>Number : NumberConstructor
21+
22+
class C6 extends Date { }
23+
>C6 : C6
24+
>Date : DateConstructor
25+
26+
class C7 extends RegExp { }
27+
>C7 : C7
28+
>RegExp : RegExpConstructor
29+
30+
class C8 extends Error { }
31+
>C8 : C8
32+
>Error : ErrorConstructor
33+
34+
class C9 extends Array { }
35+
>C9 : C9
36+
>Array : ArrayConstructor
37+
38+
class C10 extends Array<number> { }
39+
>C10 : C10
40+
>Array : ArrayConstructor
41+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(7,18): error TS2304: Cannot find name 'Base'.
2+
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(45,18): error TS2508: No base constructor has the specified number of type arguments.
3+
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(56,18): error TS2510: Base constructors must all have the same return type.
4+
5+
6+
==== tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts (3 errors) ====
7+
interface Base<T, U> {
8+
x: T;
9+
y: U;
10+
}
11+
12+
// Error, no Base constructor function
13+
class D0 extends Base<string, string> {
14+
~~~~
15+
!!! error TS2304: Cannot find name 'Base'.
16+
}
17+
18+
interface BaseConstructor {
19+
new (x: string, y: string): Base<string, string>;
20+
new <T>(x: T): Base<T, T>;
21+
new <T>(x: T, y: T): Base<T, T>;
22+
new <T, U>(x: T, y: U): Base<T, U>;
23+
}
24+
25+
declare function getBase(): BaseConstructor;
26+
27+
class D1 extends getBase() {
28+
constructor() {
29+
super("abc", "def");
30+
this.x = "x";
31+
this.y = "y";
32+
}
33+
}
34+
35+
class D2 extends getBase() <number> {
36+
constructor() {
37+
super(10);
38+
super(10, 20);
39+
this.x = 1;
40+
this.y = 2;
41+
}
42+
}
43+
44+
class D3 extends getBase() <string, number> {
45+
constructor() {
46+
super("abc", 42);
47+
this.x = "x";
48+
this.y = 2;
49+
}
50+
}
51+
52+
// Error, no constructors with three type arguments
53+
class D4 extends getBase() <string, string, string> {
54+
~~~~~~~~~
55+
!!! error TS2508: No base constructor has the specified number of type arguments.
56+
}
57+
58+
interface BadBaseConstructor {
59+
new (x: string): Base<string, string>;
60+
new (x: number): Base<number, number>;
61+
}
62+
63+
declare function getBadBase(): BadBaseConstructor;
64+
65+
// Error, constructor return types differ
66+
class D5 extends getBadBase() {
67+
~~~~~~~~~~~~
68+
!!! error TS2510: Base constructors must all have the same return type.
69+
}
70+
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
//// [classExtendingClassLikeType.ts]
2+
interface Base<T, U> {
3+
x: T;
4+
y: U;
5+
}
6+
7+
// Error, no Base constructor function
8+
class D0 extends Base<string, string> {
9+
}
10+
11+
interface BaseConstructor {
12+
new (x: string, y: string): Base<string, string>;
13+
new <T>(x: T): Base<T, T>;
14+
new <T>(x: T, y: T): Base<T, T>;
15+
new <T, U>(x: T, y: U): Base<T, U>;
16+
}
17+
18+
declare function getBase(): BaseConstructor;
19+
20+
class D1 extends getBase() {
21+
constructor() {
22+
super("abc", "def");
23+
this.x = "x";
24+
this.y = "y";
25+
}
26+
}
27+
28+
class D2 extends getBase() <number> {
29+
constructor() {
30+
super(10);
31+
super(10, 20);
32+
this.x = 1;
33+
this.y = 2;
34+
}
35+
}
36+
37+
class D3 extends getBase() <string, number> {
38+
constructor() {
39+
super("abc", 42);
40+
this.x = "x";
41+
this.y = 2;
42+
}
43+
}
44+
45+
// Error, no constructors with three type arguments
46+
class D4 extends getBase() <string, string, string> {
47+
}
48+
49+
interface BadBaseConstructor {
50+
new (x: string): Base<string, string>;
51+
new (x: number): Base<number, number>;
52+
}
53+
54+
declare function getBadBase(): BadBaseConstructor;
55+
56+
// Error, constructor return types differ
57+
class D5 extends getBadBase() {
58+
}
59+
60+
61+
//// [classExtendingClassLikeType.js]
62+
var __extends = (this && this.__extends) || function (d, b) {
63+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
64+
function __() { this.constructor = d; }
65+
__.prototype = b.prototype;
66+
d.prototype = new __();
67+
};
68+
// Error, no Base constructor function
69+
var D0 = (function (_super) {
70+
__extends(D0, _super);
71+
function D0() {
72+
_super.apply(this, arguments);
73+
}
74+
return D0;
75+
})(Base);
76+
var D1 = (function (_super) {
77+
__extends(D1, _super);
78+
function D1() {
79+
_super.call(this, "abc", "def");
80+
this.x = "x";
81+
this.y = "y";
82+
}
83+
return D1;
84+
})(getBase());
85+
var D2 = (function (_super) {
86+
__extends(D2, _super);
87+
function D2() {
88+
_super.call(this, 10);
89+
_super.call(this, 10, 20);
90+
this.x = 1;
91+
this.y = 2;
92+
}
93+
return D2;
94+
})(getBase());
95+
var D3 = (function (_super) {
96+
__extends(D3, _super);
97+
function D3() {
98+
_super.call(this, "abc", 42);
99+
this.x = "x";
100+
this.y = 2;
101+
}
102+
return D3;
103+
})(getBase());
104+
// Error, no constructors with three type arguments
105+
var D4 = (function (_super) {
106+
__extends(D4, _super);
107+
function D4() {
108+
_super.apply(this, arguments);
109+
}
110+
return D4;
111+
})(getBase());
112+
// Error, constructor return types differ
113+
var D5 = (function (_super) {
114+
__extends(D5, _super);
115+
function D5() {
116+
_super.apply(this, arguments);
117+
}
118+
return D5;
119+
})(getBadBase());

0 commit comments

Comments
 (0)