• Robert Knight's avatar
    Extract `initialState` property into a separate argument · a1183565
    Robert Knight authored
    Extract the `initialState` property out of the `config` object passed
    to `createStoreModule` into a separate argument which is passed before
    `config`. This allows TypeScript to infer the type of fields/parameters
    etc. which refer to the module state while processing the `config`
    argument.
    
    For example, given the following:
    
    ```
    export default createStoreModule(initialState, {
      reducers: {
        updateThing(state, action) {
          ...
        }
      }
    });
    ```
    
    TS can infer the type of the `state` argument to `updateThing` without
    needing to explicitly annotate it. The same approach can work for other
    fields as well. This inference does not work when `initialState` is a
    property of the `config` object however.
    a1183565
create-store-test.js 4.4 KB