Why does TypeScript infer the ‘never’ type when reducing an Array with concat?

I believe this is because the type for [] is inferred to be never[], which is the type for an array that MUST be empty. You can use a type cast to address this:

['a', 'b', 'c'].reduce((accumulator, value) => accumulator.concat(value), [] as string[]);

Normally this wouldn’t be much of a problem since TypeScript does a decent job at figuring out a better type to assign to an empty array based on what you do with it. However, since your example is ‘silly’ as you put it, TypeScript isn’t able to make any inferences and leaves the type as never[].

Leave a Comment