Skip to content

Commit

Permalink
upgrade TS, prepare minimum reproduction of problems to post issue at TS
Browse files Browse the repository at this point in the history
  • Loading branch information
KiaraGrouwstra committed Dec 11, 2016
1 parent 9c33393 commit 284034f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ declare namespace R {
/**
* Returns a curried equivalent of the provided function.
*/
curry<T1, TResult>(fn: (a: T1) => TResult): CurriedFn1<T1, TResult>;
curry<T1, T2, TResult>(fn: (a: T1, b: T2) => TResult): CurriedFn2<T1, T2, TResult>;
curry<T1, T2, T3, TResult>(fn: (a: T1, b: T2, c: T3) => TResult): CurriedFn3<T1, T2, T3, TResult>;
curry<T1, T2, T3, T4, TResult>(fn: (a: T1, b: T2, c: T3, d: T4) => TResult): CurriedFn4<T1, T2, T3, T4, TResult>;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"devDependencies": {
"ramda": "0.22.1",
"typescript": "2.2.0-dev.20161127"
"typescript": "^2.2.0-dev.20161211"
},
"typings": "index.d.ts"
}
34 changes: 29 additions & 5 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2441,9 +2441,15 @@ class Why {

() => {
// #86: lose generics in compose
let a: { [index: string]: string } = R.fromPairs([['1','A'], ['2','B'], ['3','C']])
let b: { [index: string]: string } = R.compose(R.fromPairs)([[1,'A'], [2,'B'], [3,'C']])
let c: { [index: string]: string } = R.compose(R.fromPairs)([['1','A'], ['2','B'], ['3','C']])
type so = { [index: string]: string };
let pairs = [['1','A'], ['2','B'], ['3','C']];
let a1: so = R.fromPairs ([['1','A'], ['2','B'], ['3','C']])
let a2: so = R.fromPairs (pairs); // fails -- variable reduced to string[][], killing tuples
let b1: so = R.pipe (R.fromPairs)([['1','A'], ['2','B'], ['3','C']]) // fails, generics turn to {} => {}
let c1: so = R.compose(R.fromPairs)([['1','A'], ['2','B'], ['3','C']]) // fails, generics turn to {} => {}

// generics in pipe loses generics
R.pipe(R.identity)
}

() => {
Expand All @@ -2461,12 +2467,30 @@ class Why {

() => {
// #92: lose generics in compose

// can't infer cond paths, must annotate:
const x: <T>(v: T) => T = R.cond([
[R.F, R.F],
[R.T, R.identity]
]);
// ^ also can't infer cond paths
const y: (v: number) => number = R.compose(x, R.inc);
// argument order matters for some reason...
const y: (v: number) => number = R.pipe (R.inc, x); // ok
const z: (v: number) => number = R.compose(x, R.inc); // boom

// don't use generics in pipe/compose/curry if it can't resolve them right away:
let pipeF0 = R.pipe (R.identity); // : (v: {}) => {}
let compF0 = R.compose(R.identity); // : (v: {}) => {}

// argument order matters too:
let pipeF1 = R.pipe (R.inc, R.identity); // : (v: number) => number
let compF1 = R.compose(R.identity, R.inc); // : (v: number) => {}
let res2a: number = compF1(1); // uh-oh, fails

// also can't reason backward:
let compF2 = R.compose(R.inc, R.identity); // : (v: {}) => number
let res3b: number = compF2('foo'); // uh-oh, passes
let pipeF2 = R.pipe (R.identity, R.inc); // : (v: {}) => number
let res4b: number = pipeF2('foo'); // uh-oh, passes
}

() => {
Expand Down

0 comments on commit 284034f

Please sign in to comment.