Skip to content

Commit 53cbea7

Browse files
committed
Add tests
1 parent 3e79e8d commit 53cbea7

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/cases/compiler/genericFunctionInference1.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,53 @@ declare function baz<T, U extends T>(t1: T, t2: T, u: U): [T, U];
6565

6666
let f60 = wrap3(baz);
6767

68+
declare const list2: {
69+
<T>(a: T): T[];
70+
foo: string;
71+
bar(): number;
72+
}
73+
74+
let f70 = pipe(list2, box);
75+
let f71 = pipe(box, list2);
76+
77+
declare class Point {
78+
constructor(x: number, y: number);
79+
readonly x: number;
80+
readonly y: number;
81+
}
82+
83+
declare class Bag<T> {
84+
constructor(...args: T[]);
85+
contains(value: T): boolean;
86+
static foo: string;
87+
}
88+
89+
function asFunction<A extends any[], B>(cf: new (...args: A) => B) {
90+
return (...args: A) => new cf(...args);
91+
}
92+
93+
const newPoint = asFunction(Point);
94+
const newBag = asFunction(Bag);
95+
const p1 = new Point(10, 20);
96+
const p2 = newPoint(10, 20);
97+
const bag1 = new Bag(1, 2, 3);
98+
const bag2 = newBag('a', 'b', 'c');
99+
100+
declare class Comp<P> {
101+
props: P;
102+
constructor(props: P);
103+
}
104+
105+
type CompClass<P> = new (props: P) => Comp<P>;
106+
107+
declare function myHoc<P>(C: CompClass<P>): CompClass<P>;
108+
109+
type GenericProps<T> = { foo: number, stuff: T };
110+
111+
declare class GenericComp<T> extends Comp<GenericProps<T>> {}
112+
113+
const GenericComp2 = myHoc(GenericComp);
114+
68115
// #417
69116

70117
function mirror<A, B>(f: (a: A) => B): (a: A) => B { return f; }

0 commit comments

Comments
 (0)