1. 31 Mar, 2022 4 commits
  2. 30 Mar, 2022 6 commits
  3. 29 Mar, 2022 5 commits
  4. 28 Mar, 2022 13 commits
  5. 25 Mar, 2022 2 commits
  6. 24 Mar, 2022 3 commits
    • Robert Knight's avatar
      Introduce a pattern for fully typed store modules · 9d40fff9
      Robert Knight authored
      Introduce a pattern for creating store modules which are fully typed,
      using the "activity" module as a test case / example. This allows
      TypeScript to check both external usage of the module, as well as
      internal consistency between the different elements of it (initial
      state, reducers, action creators, selectors).
      
      The elements of this pattern are:
      
       - A `State` type is defined in each module, which is typically whatever
         shape the module's initial state has.
      
       - Each function in the `reducers` map specifies the type of its `state`
         parameter as `State` and defines the fields of the action.
      
       - Action creators use a new `makeAction` helper, which ensures that the
         type of dispatched actions matches what the reducer expects
      
       - The `createStoreModule` helper ties all the elements of the module
         (reducers, actions, selectors) together and makes sure they are
         consistent with one another.
      
      The general structure of a typed store module, to which the various existing
      modules will converge, is:
      
      ```js
      import { createStoreModule, makeAction } from '../create-store';
      
      const initialState = { ... }
      
      /** @typedef {typeof initialState} State */
      
      const reducers = {
        /**
         * @param {State} state
         * @param {{ id: string }} action
         */
        SOME_ACTION(state, action) {
          ...
        }
      }
      
      /**
       * @param {string} id
       */
      function someAction(id) {
        return makeAction(reducers, 'SOME_ACTION', { id });
      }
      
      /**
       * @param {State}
       */
      function someSelector(state) {
        ...
      }
      
      export someModule = createStoreModule(initialState, {
        namespace: 'someModule',
        reducers,
        actionCreators: { someAction },
        selectors: { someSelector },
      });
      ```
      9d40fff9
    • Robert Knight's avatar
      Remove `DefaultIfAny` helper · 788697ec
      Robert Knight authored
      Remove a cryptic piece of code that is no longer needed given the ability to
      specify default values for template arguments [1]
      
      [1] https://github.com/microsoft/TypeScript/pull/45483
      788697ec
    • Lyza Danger Gardner's avatar
      a95447b1
  7. 23 Mar, 2022 6 commits
  8. 22 Mar, 2022 1 commit