Skip to content

Commit 615784a

Browse files
committed
Add tests
1 parent ad71da0 commit 615784a

File tree

3 files changed

+144
-0
lines changed

3 files changed

+144
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// @strictNullChecks: true
2+
3+
type T1 = { a: number };
4+
type T2 = T1 & { b: number };
5+
type T3 = () => void;
6+
type T4 = new () => { a: number };
7+
type T5 = number[];
8+
type T6 = [string, number];
9+
type T7 = { [P in 'a' | 'b' | 'c']: string };
10+
11+
interface I1 extends T1 { x: string }
12+
interface I2 extends T2 { x: string }
13+
interface I3 extends T3 { x: string }
14+
interface I4 extends T4 { x: string }
15+
interface I5 extends T5 { x: string }
16+
interface I6 extends T6 { x: string }
17+
interface I7 extends T7 { x: string }
18+
19+
type Constructor<T> = new () => T;
20+
declare function Constructor<T>(): Constructor<T>;
21+
22+
class C1 extends Constructor<I1>() { x: string }
23+
class C2 extends Constructor<I2>() { x: string }
24+
class C3 extends Constructor<I3>() { x: string }
25+
class C4 extends Constructor<I4>() { x: string }
26+
class C5 extends Constructor<I5>() { x: string }
27+
class C6 extends Constructor<I6>() { x: string }
28+
class C7 extends Constructor<I7>() { x: string }
29+
30+
declare function fx(x: string): string;
31+
declare class CX { a: number }
32+
declare enum EX { A, B, C }
33+
declare namespace NX { export const a = 1 }
34+
35+
type T10 = typeof fx;
36+
type T11 = typeof CX;
37+
type T12 = typeof EX;
38+
type T13 = typeof NX;
39+
40+
interface I10 extends T10 { x: string }
41+
interface I11 extends T11 { x: string }
42+
interface I12 extends T12 { x: string }
43+
interface I13 extends T13 { x: string }
44+
45+
type Identifiable<T> = { _id: string } & T;
46+
47+
interface I20 extends Partial<T1> { x: string }
48+
interface I21 extends Readonly<T1> { x: string }
49+
interface I22 extends Identifiable<T1> { x: string }
50+
interface I23 extends Identifiable<T1 & { b: number}> { x: string }
51+
52+
class C20 extends Constructor<Partial<T1>>() { x: string }
53+
class C21 extends Constructor<Readonly<T1>>() { x: string }
54+
class C22 extends Constructor<Identifiable<T1>>() { x: string }
55+
class C23 extends Constructor<Identifiable<T1 & { b: number}>>() { x: string }
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// @strictNullChecks: true
2+
3+
type T1 = { a: number };
4+
type T2 = T1 & { b: number };
5+
type T3 = number[];
6+
type T4 = [string, number];
7+
type T5 = { [P in 'a' | 'b' | 'c']: string };
8+
9+
interface I1 extends T1 { a: string }
10+
interface I2 extends T2 { b: string }
11+
interface I3 extends T3 { length: string }
12+
interface I4 extends T4 { 0: number }
13+
interface I5 extends T5 { c: number }
14+
15+
type Constructor<T> = new () => T;
16+
declare function Constructor<T>(): Constructor<T>;
17+
18+
class C1 extends Constructor<T1>() { a: string }
19+
class C2 extends Constructor<T2>() { b: string }
20+
class C3 extends Constructor<T3>() { length: string }
21+
class C4 extends Constructor<T4>() { 0: number }
22+
class C5 extends Constructor<T5>() { c: number }
23+
24+
declare class CX { static a: string }
25+
declare enum EX { A, B, C }
26+
declare namespace NX { export const a = "hello" }
27+
28+
type TCX = typeof CX;
29+
type TEX = typeof EX;
30+
type TNX = typeof NX;
31+
32+
interface I10 extends TCX { a: number }
33+
interface I11 extends TEX { C: string }
34+
interface I12 extends TNX { a: number }
35+
interface I14 extends TCX { [x: string]: number }
36+
interface I15 extends TEX { [x: string]: number }
37+
interface I16 extends TNX { [x: string]: number }
38+
39+
type Identifiable<T> = { _id: string } & T;
40+
41+
interface I20 extends Partial<T1> { a: string }
42+
interface I21 extends Readonly<T1> { a: string }
43+
interface I22 extends Identifiable<T1> { a: string }
44+
interface I23 extends Identifiable<T1 & { b: number}> { a: string }
45+
46+
type U = { a: number } | { b: string };
47+
48+
interface I30 extends U { x: string }
49+
interface I31<T> extends T { x: string }
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
interface Thing1 {
2+
a: number;
3+
self(): this;
4+
}
5+
6+
interface Thing2 {
7+
b: number;
8+
me(): this;
9+
}
10+
11+
type Thing3 = Thing1 & Thing2;
12+
type Thing4 = Thing3 & string[];
13+
14+
function f1(t: Thing3) {
15+
t = t.self();
16+
t = t.me().self().me();
17+
}
18+
19+
interface Thing5 extends Thing4 {
20+
c: string;
21+
}
22+
23+
function f2(t: Thing5) {
24+
t = t.self();
25+
t = t.me().self().me();
26+
}
27+
28+
interface Component {
29+
extend<T>(props: T): this & T;
30+
}
31+
32+
interface Label extends Component {
33+
title: string;
34+
}
35+
36+
function test(label: Label) {
37+
const extended = label.extend({ id: 67 }).extend({ tag: "hello" });
38+
extended.id; // Ok
39+
extended.tag; // Ok
40+
}

0 commit comments

Comments
 (0)