Skip to content

Commit 304e25c

Browse files
committed
Add tests
1 parent 91f8fc6 commit 304e25c

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// @strict: true
2+
// @target: es2015
3+
4+
declare function pipe<A extends any[], B>(ab: (...args: A) => B): (...args: A) => B;
5+
declare function pipe<A extends any[], B, C>(ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C;
6+
declare function pipe<A extends any[], B, C, D>(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D;
7+
8+
declare function list<T>(a: T): T[];
9+
declare function box<V>(x: V): { value: V };
10+
11+
const f00 = pipe(list);
12+
const f01 = pipe(list, box);
13+
const f02 = pipe(x => list(x), box);
14+
const f03 = pipe(list, x => box(x));
15+
const f04 = pipe(x => list(x), x => box(x))
16+
const f05 = pipe(list, pipe(box));
17+
const f06 = pipe(x => list(x), pipe(box));
18+
const f07 = pipe(x => list(x), pipe(x => box(x)));
19+
20+
const f10: <T>(x: T) => T[] = pipe(list);
21+
const f11: <T>(x: T) => { value: T[] } = pipe(list, box);
22+
const f12: <T>(x: T) => { value: T[] } = pipe(x => list(x), box);
23+
const f13: <T>(x: T) => { value: T[] } = pipe(list, x => box(x));
24+
const f14: <T>(x: T) => { value: T[] } = pipe(x => list(x), x => box(x))
25+
const f15: <T>(x: T) => { value: T[] } = pipe(list, pipe(box));
26+
const f16: <T>(x: T) => { value: T[] } = pipe(x => list(x), pipe(box));
27+
const f17: <T>(x: T) => { value: T[] } = pipe(x => list(x), pipe(x => box(x)));
28+
29+
// #29904.2
30+
31+
const fn20 = pipe((_a?: {}) => 1);
32+
33+
// #29904.3
34+
35+
type Fn = (n: number) => number;
36+
const fn30: Fn = pipe(
37+
x => x + 1,
38+
x => x * 2,
39+
);
40+
41+
const promise = Promise.resolve(1);
42+
promise.then(
43+
pipe(
44+
x => x + 1,
45+
x => x * 2,
46+
),
47+
);
48+
49+
// #29904.4
50+
51+
declare const getString: () => string;
52+
declare const orUndefined: (name: string) => string | undefined;
53+
declare const identity: <T>(value: T) => T;
54+
55+
const fn40 = pipe(
56+
getString,
57+
string => orUndefined(string),
58+
identity,
59+
);
60+
61+
// #29904.6
62+
63+
declare const getArray: () => string[];
64+
declare const first: <T>(ts: T[]) => T;
65+
66+
const fn60 = pipe(
67+
getArray,
68+
x => x,
69+
first,
70+
);
71+
72+
const fn61 = pipe(
73+
getArray,
74+
identity,
75+
first,
76+
);
77+
78+
const fn62 = pipe(
79+
getArray,
80+
x => x,
81+
x => first(x),
82+
);

0 commit comments

Comments
 (0)