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 … Read more

Can I dispatch an action in reducer?

Starting another dispatch before your reducer is finished is an anti-pattern, because the state you received at the beginning of your reducer will not be the current application state anymore when your reducer finishes. But scheduling another dispatch from within a reducer is NOT an anti-pattern. In fact, that is what the Elm language does, … Read more