typed-typings / npm-ramda

TypeScript's type definitions for Ramda
MIT License
384 stars 64 forks source link

Using groupBy with path always fails typecheck #434

Open buzzin0609 opened 5 years ago

buzzin0609 commented 5 years ago

Hi,

I come across this issue where using groupBy(path(['some', 'path']) will always fail the typechecking as the path definition of path is to return T | undefined. You get the "Type string | undefined does not match....".

I'm not entirely sure of the best way you could handle this as the typing is correct to how path works, but thought it was worth opening an issue to see your thoughts.

For anyone who is stuck on how to make the typechecking pass, you can do something like the below:

groupBy<MyType>(path(['some', 'deep', 'prop']) as (a: MyType) => string);

You can always use as any but that's not always an ideal solution. :)