Skip to content

Commit 4051d73

Browse files
committed
Accept new baselines
1 parent 53cbea7 commit 4051d73

File tree

4 files changed

+633
-233
lines changed

4 files changed

+633
-233
lines changed

tests/baselines/reference/genericFunctionInference1.errors.txt

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/compiler/genericFunctionInference1.ts(88,14): error TS2345: Argument of type '<a>(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'.
1+
tests/cases/compiler/genericFunctionInference1.ts(135,14): error TS2345: Argument of type '<a>(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'.
22
Type 'number' is not assignable to type 'string'.
33

44

@@ -67,6 +67,53 @@ tests/cases/compiler/genericFunctionInference1.ts(88,14): error TS2345: Argument
6767

6868
let f60 = wrap3(baz);
6969

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

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

tests/baselines/reference/genericFunctionInference1.js

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

6464
let f60 = wrap3(baz);
6565

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

68115
function mirror<A, B>(f: (a: A) => B): (a: A) => B { return f; }
@@ -242,6 +289,18 @@ const f40 = pipe4([list, box]);
242289
const f41 = pipe4([box, list]);
243290
const f50 = pipe5(list); // No higher order inference
244291
let f60 = wrap3(baz);
292+
let f70 = pipe(list2, box);
293+
let f71 = pipe(box, list2);
294+
function asFunction(cf) {
295+
return (...args) => new cf(...args);
296+
}
297+
const newPoint = asFunction(Point);
298+
const newBag = asFunction(Bag);
299+
const p1 = new Point(10, 20);
300+
const p2 = newPoint(10, 20);
301+
const bag1 = new Bag(1, 2, 3);
302+
const bag2 = newBag('a', 'b', 'c');
303+
const GenericComp2 = myHoc(GenericComp);
245304
// #417
246305
function mirror(f) { return f; }
247306
var identityM = mirror(identity);

0 commit comments

Comments
 (0)