json-to-ts icon indicating copy to clipboard operation
json-to-ts copied to clipboard

Reduce of empty array with no initial value

Open linonetwo opened this issue 4 years ago • 0 comments

https://pastebin.com/tnx6CH5a

This JSON, will cause

TypeError: Reduce of empty array with no initial value
    at Array.reduce (<anonymous>)
    at pascalCase (.../node_modules/json-to-ts/build/src/get-names.js:82:10)

I tried change

- .reduce(function (a, b) { return a + b; });
+ .reduce(function (a, b) { return a + b; }, '');

And it works.

I think this workaround is not good enough, there maybe a bigger problem inside.

linonetwo avatar Dec 07 '20 17:12 linonetwo