knpwrs / redux-ts-utils

Everything you need to create type-safe applications with Redux!
MIT License
55 stars 4 forks source link

using createAction without type parameters is unsafe #28

Open mixvar opened 5 years ago

mixvar commented 5 years ago

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.