neurosnap / robodux

caching in redux made simple
MIT License
101 stars 7 forks source link

Possibility to have actions get typed? #3

Closed venkatd closed 6 years ago

venkatd commented 6 years ago

Hi again. I'm pretty new to typescript so not sure if the following is possible.

Currently I am writing code like: yield put( Reducer.actions.commandsLoaded(commands) )

and i my reducer I have something like the following:

robodux<StoreState>({
  initialState: {commands: [], events: []},
  actions: {
    commandsLoaded(state: StoreState, commands: Command[]) {
      pushMany(state.commands, commands)
      return state
  }

However, Reducer.actions. doesn't give me code completion. And when I type Reducer.action.commandsLoaded I don't get type signature or type checking.

It would be really cool if it were possible to have the type signatures flow through.

neurosnap commented 6 years ago

We might have to pass another type to robodux that contains and interface if it isn't working properly for you now. I'll definitely take a look into this issue because I want good typings for these actions as well.

venkatd commented 6 years ago

Great, thanks!

neurosnap commented 6 years ago

You should have better typing now: https://www.npmjs.com/package/robodux/v/1.1.3

Closing the issue for now. Feel free to follow up.