Skip to content

Commit 284034f

Browse files
upgrade TS, prepare minimum reproduction of problems to post issue at TS
microsoft/TypeScript#12838
1 parent 9c33393 commit 284034f

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ declare namespace R {
603603
/**
604604
* Returns a curried equivalent of the provided function.
605605
*/
606+
curry<T1, TResult>(fn: (a: T1) => TResult): CurriedFn1<T1, TResult>;
606607
curry<T1, T2, TResult>(fn: (a: T1, b: T2) => TResult): CurriedFn2<T1, T2, TResult>;
607608
curry<T1, T2, T3, TResult>(fn: (a: T1, b: T2, c: T3) => TResult): CurriedFn3<T1, T2, T3, TResult>;
608609
curry<T1, T2, T3, T4, TResult>(fn: (a: T1, b: T2, c: T3, d: T4) => TResult): CurriedFn4<T1, T2, T3, T4, TResult>;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"devDependencies": {
88
"ramda": "0.22.1",
9-
"typescript": "2.2.0-dev.20161127"
9+
"typescript": "^2.2.0-dev.20161211"
1010
},
1111
"typings": "index.d.ts"
1212
}

test.ts

+29-5
Original file line numberDiff line numberDiff line change
@@ -2441,9 +2441,15 @@ class Why {
24412441

24422442
() => {
24432443
// #86: lose generics in compose
2444-
let a: { [index: string]: string } = R.fromPairs([['1','A'], ['2','B'], ['3','C']])
2445-
let b: { [index: string]: string } = R.compose(R.fromPairs)([[1,'A'], [2,'B'], [3,'C']])
2446-
let c: { [index: string]: string } = R.compose(R.fromPairs)([['1','A'], ['2','B'], ['3','C']])
2444+
type so = { [index: string]: string };
2445+
let pairs = [['1','A'], ['2','B'], ['3','C']];
2446+
let a1: so = R.fromPairs ([['1','A'], ['2','B'], ['3','C']])
2447+
let a2: so = R.fromPairs (pairs); // fails -- variable reduced to string[][], killing tuples
2448+
let b1: so = R.pipe (R.fromPairs)([['1','A'], ['2','B'], ['3','C']]) // fails, generics turn to {} => {}
2449+
let c1: so = R.compose(R.fromPairs)([['1','A'], ['2','B'], ['3','C']]) // fails, generics turn to {} => {}
2450+
2451+
// generics in pipe loses generics
2452+
R.pipe(R.identity)
24472453
}
24482454

24492455
() => {
@@ -2461,12 +2467,30 @@ class Why {
24612467

24622468
() => {
24632469
// #92: lose generics in compose
2470+
2471+
// can't infer cond paths, must annotate:
24642472
const x: <T>(v: T) => T = R.cond([
24652473
[R.F, R.F],
24662474
[R.T, R.identity]
24672475
]);
2468-
// ^ also can't infer cond paths
2469-
const y: (v: number) => number = R.compose(x, R.inc);
2476+
// argument order matters for some reason...
2477+
const y: (v: number) => number = R.pipe (R.inc, x); // ok
2478+
const z: (v: number) => number = R.compose(x, R.inc); // boom
2479+
2480+
// don't use generics in pipe/compose/curry if it can't resolve them right away:
2481+
let pipeF0 = R.pipe (R.identity); // : (v: {}) => {}
2482+
let compF0 = R.compose(R.identity); // : (v: {}) => {}
2483+
2484+
// argument order matters too:
2485+
let pipeF1 = R.pipe (R.inc, R.identity); // : (v: number) => number
2486+
let compF1 = R.compose(R.identity, R.inc); // : (v: number) => {}
2487+
let res2a: number = compF1(1); // uh-oh, fails
2488+
2489+
// also can't reason backward:
2490+
let compF2 = R.compose(R.inc, R.identity); // : (v: {}) => number
2491+
let res3b: number = compF2('foo'); // uh-oh, passes
2492+
let pipeF2 = R.pipe (R.identity, R.inc); // : (v: {}) => number
2493+
let res4b: number = pipeF2('foo'); // uh-oh, passes
24702494
}
24712495

24722496
() => {

0 commit comments

Comments
 (0)