From 0509fcf2a6b4b4b70c70bc692b14016742396ad5 Mon Sep 17 00:00:00 2001 From: Paul Sachs Date: Mon, 21 Aug 2017 18:30:27 -0400 Subject: [PATCH] Unifying values declaration causes param to cast to any instead of proper generic type Breaks linting but fixes typescript behavior. --- types/ramda/index.d.ts | 2 +- types/ramda/ramda-tests.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 5a8ea8f332..f36cd90b84 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -1916,7 +1916,7 @@ declare namespace R { * Note that the order of the output array is not guaranteed across * different JS platforms. */ - values(obj: { [index: string]: T } | any): T[]; + values(obj: T): Array; /** * Returns a list of all the properties, including prototype properties, of the supplied diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 909eba9d5f..2474d78d8e 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -1567,7 +1567,19 @@ class Rectangle { }; () => { - const a = R.values({a: 1, b: 2, c: 3}); // => [1, 2, 3] + interface A { + a: string; + b: string; + } + const a1: A = { a: 'something', b: 'else' }; + const v1 = R.values(a1); + + const a = R.values({a: 1, b: 2, c: 3}); // => [1, 2, 3] (number[]) + const addition = a[0] + a[1]; + + const b = R.values({a: 1, b: 'something'}); // b = (string|number)[] + const c = R.values({1: 3}); + // const d = R.values('something'); }; () => {