diff --git a/tests/cases/compiler/genericFunctionInference1.ts b/tests/cases/compiler/genericFunctionInference1.ts index c6b864f82e518..c90c94cf5e874 100644 --- a/tests/cases/compiler/genericFunctionInference1.ts +++ b/tests/cases/compiler/genericFunctionInference1.ts @@ -65,6 +65,53 @@ declare function baz(t1: T, t2: T, u: U): [T, U]; let f60 = wrap3(baz); +declare const list2: { + (a: T): T[]; + foo: string; + bar(): number; +} + +let f70 = pipe(list2, box); +let f71 = pipe(box, list2); + +declare class Point { + constructor(x: number, y: number); + readonly x: number; + readonly y: number; +} + +declare class Bag { + constructor(...args: T[]); + contains(value: T): boolean; + static foo: string; +} + +function asFunction(cf: new (...args: A) => B) { + return (...args: A) => new cf(...args); +} + +const newPoint = asFunction(Point); +const newBag = asFunction(Bag); +const p1 = new Point(10, 20); +const p2 = newPoint(10, 20); +const bag1 = new Bag(1, 2, 3); +const bag2 = newBag('a', 'b', 'c'); + +declare class Comp

{ + props: P; + constructor(props: P); +} + +type CompClass

= new (props: P) => Comp

; + +declare function myHoc

(C: CompClass

): CompClass

; + +type GenericProps = { foo: number, stuff: T }; + +declare class GenericComp extends Comp> {} + +const GenericComp2 = myHoc(GenericComp); + // #417 function mirror(f: (a: A) => B): (a: A) => B { return f; }