Closed
Description
TypeScript Version: 2.2.2
This possible typings of props function from ramda for two arguments:
I wonder why if second object argument is not curried TS can not infer types in results:
declare function props<P1 extends string, P2 extends string, T1, T2>
(ps: [P1, P2], obj: {[K in P1]: T2} & {[K in P2]: T2}): [T1, T2];
props(['a', 'b'], {a: 1, b: '2'})[0] => // can not infer `number` type
props(['a', 'b'], {a: 1, b: '2'})[1] => // can not infer `string` type
And when curried it can:
// this is inferred
declare function props<P1 extends string, P2 extends string>
(ps: [P1, P2]): <T1, T2>(obj: {[K in P1]: T1} & {[K2 in P2]: T2})
=> [T1, T2];
props(['a', 'b'])({a: 1, b: '2'})[0] => // this can infer `number` type
props(['a', 'b'])({a: 1, b: '2'})[1] => // this can infer `string` type
Is TS going to make it work in future?