knpwrs/redux-ts-utils

using createAction without type parameters is unsafe

mixvar opened this issue · 0 comments

currently:

 // action payload type is '{}' which is almost as bad as any
const anyAction = createAction('increment');

I think it would be safer to default to void or somehow force user to specifying type parameter and be explicit about using any:

const voidAction = createAction('increment'); // same as using <void>

// or
const illegalAction = createAction('increment'); //compile error

// still possible but explicit
const anyAction = createAction<any>('increment');

Tested with typescript 3.4.5 and all strict rules enabled.