|
| 1 | +//// [genericFunctionInference1.ts] |
| 2 | +declare function pipe<A extends any[], B>(ab: (...args: A) => B): (...args: A) => B; |
| 3 | +declare function pipe<A extends any[], B, C>(ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C; |
| 4 | +declare function pipe<A extends any[], B, C, D>(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D; |
| 5 | + |
| 6 | +declare function list<T>(a: T): T[]; |
| 7 | +declare function box<V>(x: V): { value: V }; |
| 8 | + |
| 9 | +const f00 = pipe(list); |
| 10 | +const f01 = pipe(list, box); |
| 11 | +const f02 = pipe(x => list(x), box); |
| 12 | +const f03 = pipe(list, x => box(x)); |
| 13 | +const f04 = pipe(x => list(x), x => box(x)) |
| 14 | +const f05 = pipe(list, pipe(box)); |
| 15 | +const f06 = pipe(x => list(x), pipe(box)); |
| 16 | +const f07 = pipe(x => list(x), pipe(x => box(x))); |
| 17 | + |
| 18 | +const f10: <T>(x: T) => T[] = pipe(list); |
| 19 | +const f11: <T>(x: T) => { value: T[] } = pipe(list, box); |
| 20 | +const f12: <T>(x: T) => { value: T[] } = pipe(x => list(x), box); |
| 21 | +const f13: <T>(x: T) => { value: T[] } = pipe(list, x => box(x)); |
| 22 | +const f14: <T>(x: T) => { value: T[] } = pipe(x => list(x), x => box(x)) |
| 23 | +const f15: <T>(x: T) => { value: T[] } = pipe(list, pipe(box)); |
| 24 | +const f16: <T>(x: T) => { value: T[] } = pipe(x => list(x), pipe(box)); |
| 25 | +const f17: <T>(x: T) => { value: T[] } = pipe(x => list(x), pipe(x => box(x))); |
| 26 | + |
| 27 | +// #29904.2 |
| 28 | + |
| 29 | +const fn20 = pipe((_a?: {}) => 1); |
| 30 | + |
| 31 | +// #29904.3 |
| 32 | + |
| 33 | +type Fn = (n: number) => number; |
| 34 | +const fn30: Fn = pipe( |
| 35 | + x => x + 1, |
| 36 | + x => x * 2, |
| 37 | +); |
| 38 | + |
| 39 | +const promise = Promise.resolve(1); |
| 40 | +promise.then( |
| 41 | + pipe( |
| 42 | + x => x + 1, |
| 43 | + x => x * 2, |
| 44 | + ), |
| 45 | +); |
| 46 | + |
| 47 | +// #29904.4 |
| 48 | + |
| 49 | +declare const getString: () => string; |
| 50 | +declare const orUndefined: (name: string) => string | undefined; |
| 51 | +declare const identity: <T>(value: T) => T; |
| 52 | + |
| 53 | +const fn40 = pipe( |
| 54 | + getString, |
| 55 | + string => orUndefined(string), |
| 56 | + identity, |
| 57 | +); |
| 58 | + |
| 59 | +// #29904.6 |
| 60 | + |
| 61 | +declare const getArray: () => string[]; |
| 62 | +declare const first: <T>(ts: T[]) => T; |
| 63 | + |
| 64 | +const fn60 = pipe( |
| 65 | + getArray, |
| 66 | + x => x, |
| 67 | + first, |
| 68 | +); |
| 69 | + |
| 70 | +const fn61 = pipe( |
| 71 | + getArray, |
| 72 | + identity, |
| 73 | + first, |
| 74 | +); |
| 75 | + |
| 76 | +const fn62 = pipe( |
| 77 | + getArray, |
| 78 | + x => x, |
| 79 | + x => first(x), |
| 80 | +); |
| 81 | + |
| 82 | + |
| 83 | +//// [genericFunctionInference1.js] |
| 84 | +"use strict"; |
| 85 | +const f00 = pipe(list); |
| 86 | +const f01 = pipe(list, box); |
| 87 | +const f02 = pipe(x => list(x), box); |
| 88 | +const f03 = pipe(list, x => box(x)); |
| 89 | +const f04 = pipe(x => list(x), x => box(x)); |
| 90 | +const f05 = pipe(list, pipe(box)); |
| 91 | +const f06 = pipe(x => list(x), pipe(box)); |
| 92 | +const f07 = pipe(x => list(x), pipe(x => box(x))); |
| 93 | +const f10 = pipe(list); |
| 94 | +const f11 = pipe(list, box); |
| 95 | +const f12 = pipe(x => list(x), box); |
| 96 | +const f13 = pipe(list, x => box(x)); |
| 97 | +const f14 = pipe(x => list(x), x => box(x)); |
| 98 | +const f15 = pipe(list, pipe(box)); |
| 99 | +const f16 = pipe(x => list(x), pipe(box)); |
| 100 | +const f17 = pipe(x => list(x), pipe(x => box(x))); |
| 101 | +// #29904.2 |
| 102 | +const fn20 = pipe((_a) => 1); |
| 103 | +const fn30 = pipe(x => x + 1, x => x * 2); |
| 104 | +const promise = Promise.resolve(1); |
| 105 | +promise.then(pipe(x => x + 1, x => x * 2)); |
| 106 | +const fn40 = pipe(getString, string => orUndefined(string), identity); |
| 107 | +const fn60 = pipe(getArray, x => x, first); |
| 108 | +const fn61 = pipe(getArray, identity, first); |
| 109 | +const fn62 = pipe(getArray, x => x, x => first(x)); |
0 commit comments