Hacker News new | ask | show | jobs
by mikewhy 2476 days ago
This is what my redux stuff looks like with TypeScript:

    const constants = {
      addMovie: 'movies/addMovie',
    }

    export const addMovie = createAction<string>(constants.addMovie)

    export const reducer = createReducer(initialState, {
      [constants.addMovie]: (state, action: ReturnType<typeof addMovie>) => ({
        ...state,
      })
    })
But this forgoes applying any constraints to `dispatch` / the ability to have one giant union of all possible action types your app supports.