Flowjs: Call Of Method `join`. Method Cannot Be Called On Mixed
Say I have a constant animals, which I import with import animals from './animals Say the animals constant is: { hoofed:[ 'horses', 'sheep', 'goats' ], feline: [
Solution 1:
The Object.values
function returns an Array<mixed>
type at the moment. So you need to cast it to an array of string arrays like the following.
let fq: string[][] = (Object.values(animals): any);
fq = fq
.reduce((memo, animalList) => memo + `animal:${animalList.join(' animal:')} `, '')
Or use an inline cast like this:
const fq = ((Object.values(animals): any): string[][])
.reduce((memo, animalList) => memo + `animal:${animalList.join(' animal:')} `, '')
Flow can't support this function at the moment out of the box, because the Object.values
function is in stage-4 as a proposal. So it's not part of the language yet. It should be just a matter of time that you won't need to workaround this problem with a cast, as soon as the Object.values
function is part of the EcmaScript standard, the flow team will probably implement it correctly.
Post a Comment for "Flowjs: Call Of Method `join`. Method Cannot Be Called On Mixed"