Skip to content

Commit d575259

Browse files
committed
Adding basic tests
1 parent 367e257 commit d575259

4 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class C1 extends Object { }
2+
class C2 extends Function { }
3+
class C3 extends String { }
4+
class C4 extends Boolean { }
5+
class C5 extends Number { }
6+
class C6 extends Date { }
7+
class C7 extends RegExp { }
8+
class C8 extends Error { }
9+
class C9 extends Array { }
10+
class C10 extends Array<number> { }
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
interface Base<T, U> {
2+
x: T;
3+
y: U;
4+
}
5+
6+
// Error, no Base constructor function
7+
class D0 extends Base<string, string> {
8+
}
9+
10+
interface BaseConstructor {
11+
new (x: string, y: string): Base<string, string>;
12+
new <T>(x: T): Base<T, T>;
13+
new <T>(x: T, y: T): Base<T, T>;
14+
new <T, U>(x: T, y: U): Base<T, U>;
15+
}
16+
17+
declare function getBase(): BaseConstructor;
18+
19+
class D1 extends getBase() {
20+
constructor() {
21+
super("abc", "def");
22+
this.x = "x";
23+
this.y = "y";
24+
}
25+
}
26+
27+
class D2 extends getBase() <number> {
28+
constructor() {
29+
super(10);
30+
super(10, 20);
31+
this.x = 1;
32+
this.y = 2;
33+
}
34+
}
35+
36+
class D3 extends getBase() <string, number> {
37+
constructor() {
38+
super("abc", 42);
39+
this.x = "x";
40+
this.y = 2;
41+
}
42+
}
43+
44+
// Error, no constructors with three type arguments
45+
class D4 extends getBase() <string, string, string> {
46+
}
47+
48+
interface BadBaseConstructor {
49+
new (x: string): Base<string, string>;
50+
new (x: number): Base<number, number>;
51+
}
52+
53+
declare function getBadBase(): BadBaseConstructor;
54+
55+
// Error, constructor return types differ
56+
class D5 extends getBadBase() {
57+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var x: {};
2+
3+
function foo() {
4+
this.x = 1;
5+
}
6+
7+
class C1 extends undefined { }
8+
class C2 extends true { }
9+
class C3 extends false { }
10+
class C4 extends 42 { }
11+
class C5 extends "hello" { }
12+
class C6 extends x { }
13+
class C7 extends foo { }
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class C1 extends null { }
2+
class C2 extends (null) { }

0 commit comments

Comments
 (0)