Say I have the following code:
const results = //some complex datastructure generated by a third party api call
const reducedList = results.map((item) => item.awesome_key)
.map((awesomeKeyList) => awesomeKeyList
.reduce((memo, awesomeKey) => {//stuff},{})))
This code works like a charm. Now say I decided to use Ramda for the first map through pluck like so:
import R from Ramda;
R.pluck('awesome_key', results)
.map((awesomeKeyList) => awesomeKeyList
.reduce((memo, awesomeKey) => {},{})))
This will fail with:
Property 'reduce' does not exist on type '{}'.
The types on Ramda.pluck are:
pluck<T>(p: string|number, list: any[]): T[];
pluck(p: string|number): <T>(list: any[]) => T[];
What about those types prevents me from using reduce in this manner?
An example (simplified) structure:
things: [
{
awesome_key: [{
long_name: 'string',
short_name: 'string',
types: {
0: 'string from set',
1?: 'string'
}
}]
other_fields not relevant here
}
]