Skip to content

Commit 5fe8ebb

Browse files
committed
Accept new baselines
1 parent 22c934a commit 5fe8ebb

File tree

4 files changed

+1427
-203
lines changed

4 files changed

+1427
-203
lines changed
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
tests/cases/compiler/genericFunctionInference1.ts(83,14): error TS2345: Argument of type '<a>(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'.
2+
Type 'number' is not assignable to type 'string'.
3+
4+
5+
==== tests/cases/compiler/genericFunctionInference1.ts (1 errors) ====
6+
declare function pipe<A extends any[], B>(ab: (...args: A) => B): (...args: A) => B;
7+
declare function pipe<A extends any[], B, C>(ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C;
8+
declare function pipe<A extends any[], B, C, D>(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D;
9+
10+
declare function list<T>(a: T): T[];
11+
declare function box<V>(x: V): { value: V };
12+
declare function foo<T extends { value: T }>(x: T): T;
13+
14+
const f00 = pipe(list);
15+
const f01 = pipe(list, box);
16+
const f02 = pipe(box, list);
17+
const f03 = pipe(x => list(x), box);
18+
const f04 = pipe(list, x => box(x));
19+
const f05 = pipe(x => list(x), x => box(x))
20+
const f06 = pipe(list, pipe(box));
21+
const f07 = pipe(x => list(x), pipe(box));
22+
const f08 = pipe(x => list(x), pipe(x => box(x)));
23+
const f09 = pipe(list, x => x.length);
24+
const f10 = pipe(foo);
25+
const f11 = pipe(foo, foo);
26+
27+
const g00: <T>(x: T) => T[] = pipe(list);
28+
const g01: <T>(x: T) => { value: T[] } = pipe(list, box);
29+
const g02: <T>(x: T) => { value: T }[] = pipe(box, list);
30+
const g03: <T>(x: T) => { value: T[] } = pipe(x => list(x), box);
31+
const g04: <T>(x: T) => { value: T[] } = pipe(list, x => box(x));
32+
const g05: <T>(x: T) => { value: T[] } = pipe(x => list(x), x => box(x))
33+
const g06: <T>(x: T) => { value: T[] } = pipe(list, pipe(box));
34+
const g07: <T>(x: T) => { value: T[] } = pipe(x => list(x), pipe(box));
35+
const g08: <T>(x: T) => { value: T[] } = pipe(x => list(x), pipe(x => box(x)));
36+
const g09: <T>(x: T) => number = pipe(list, x => x.length);
37+
const g10: <T extends { value: T }>(x: T) => T = pipe(foo);
38+
const g12: <T extends { value: T }>(x: T) => T = pipe(foo, foo);
39+
40+
declare function pipe2<A, B, C, D>(ab: (a: A) => B, cd: (c: C) => D): (a: [A, C]) => [B, D];
41+
42+
const f20 = pipe2(list, box);
43+
const f21 = pipe2(box, list);
44+
const f22 = pipe2(list, list);
45+
const f23 = pipe2(box, box);
46+
const f24 = pipe2(f20, f20);
47+
const f25 = pipe2(foo, foo);
48+
const f26 = pipe2(f25, f25);
49+
50+
declare function pipe3<A, B, C>(ab: (a: A) => B, ac: (a: A) => C): (a: A) => [B, C];
51+
52+
const f30 = pipe3(list, box);
53+
const f31 = pipe3(box, list);
54+
const f32 = pipe3(list, list);
55+
56+
declare function pipe4<A, B, C>(funcs: [(a: A) => B, (b: B) => C]): (a: A) => C;
57+
58+
const f40 = pipe4([list, box]);
59+
const f41 = pipe4([box, list]);
60+
61+
declare function pipe5<A, B>(f: (a: A) => B): { f: (a: A) => B };
62+
63+
const f50 = pipe5(list); // No higher order inference
64+
65+
// #417
66+
67+
function mirror<A, B>(f: (a: A) => B): (a: A) => B { return f; }
68+
var identityM = mirror(identity);
69+
70+
var x = 1;
71+
var y = identity(x);
72+
var z = identityM(x);
73+
74+
// #3038
75+
76+
export function keyOf<a>(value: { key: a; }): a {
77+
return value.key;
78+
}
79+
export interface Data {
80+
key: number;
81+
value: Date;
82+
}
83+
84+
var data: Data[] = [];
85+
86+
declare function toKeys<a>(values: a[], toKey: (value: a) => string): string[];
87+
88+
toKeys(data, keyOf); // Error
89+
~~~~~
90+
!!! error TS2345: Argument of type '<a>(value: { key: a; }) => a' is not assignable to parameter of type '(value: Data) => string'.
91+
!!! error TS2345: Type 'number' is not assignable to type 'string'.
92+
93+
// #9366
94+
95+
function flip<a, b, c>(f: (a: a, b: b) => c): (b: b, a: a) => c {
96+
return (b: b, a: a) => f(a, b);
97+
}
98+
function zip<T, U>(x: T, y: U): [T, U] {
99+
return [x, y];
100+
}
101+
102+
var expected: <T, U>(y: U, x: T) => [T, U] = flip(zip);
103+
var actual = flip(zip);
104+
105+
// #9366
106+
107+
const map = <T, U>(transform: (t: T) => U) =>
108+
(arr: T[]) => arr.map(transform)
109+
110+
const identityStr = (t: string) => t;
111+
112+
const arr: string[] = map(identityStr)(['a']);
113+
const arr1: string[] = map(identity)(['a']);
114+
115+
// #9949
116+
117+
function of2<a, b>(one: a, two: b): [a, b] {
118+
return [one, two];
119+
}
120+
121+
const flipped = flip(of2);
122+
123+
// #29904.1
124+
125+
type Component<P> = (props: P) => {};
126+
127+
declare const myHoc1: <P>(C: Component<P>) => Component<P>;
128+
declare const myHoc2: <P>(C: Component<P>) => Component<P>;
129+
130+
declare const MyComponent1: Component<{ foo: 1 }>;
131+
132+
const enhance = pipe(
133+
myHoc1,
134+
myHoc2,
135+
);
136+
137+
const MyComponent2 = enhance(MyComponent1);
138+
139+
// #29904.2
140+
141+
const fn20 = pipe((_a?: {}) => 1);
142+
143+
// #29904.3
144+
145+
type Fn = (n: number) => number;
146+
const fn30: Fn = pipe(
147+
x => x + 1,
148+
x => x * 2,
149+
);
150+
151+
const promise = Promise.resolve(1);
152+
promise.then(
153+
pipe(
154+
x => x + 1,
155+
x => x * 2,
156+
),
157+
);
158+
159+
// #29904.4
160+
161+
declare const getString: () => string;
162+
declare const orUndefined: (name: string) => string | undefined;
163+
declare const identity: <T>(value: T) => T;
164+
165+
const fn40 = pipe(
166+
getString,
167+
string => orUndefined(string),
168+
identity,
169+
);
170+
171+
// #29904.6
172+
173+
declare const getArray: () => string[];
174+
declare const first: <T>(ts: T[]) => T;
175+
176+
const fn60 = pipe(
177+
getArray,
178+
x => x,
179+
first,
180+
);
181+
182+
const fn61 = pipe(
183+
getArray,
184+
identity,
185+
first,
186+
);
187+
188+
const fn62 = pipe(
189+
getArray,
190+
x => x,
191+
x => first(x),
192+
);
193+

0 commit comments

Comments
 (0)