title: Lexical scoping error, property undefined
body: <p>My linter warned me about a lexical scoping error in my <code>reducer</code>, I moved my declaration out of the <code>switch</code> statement like so:</p>
  
  <pre><code>export function eventsForMonth(state = {}, action) {
      const { events: {}, day: {} } = action.data;
      const newItems = {};
  
      switch (action.type) {
          case "EVENTS_MONTH":
              Object.keys(events).map(event =&gt; {
                  newItems[event] = [...events[event].dots];
              });
  
              for (let i = -15; i &lt; 85; i++) {
                  const time = day.timestamp + i * 24 * 60 * 60 * 1000;
                  const strTime = timeToString(time);
                  if (!newItems[strTime]) {
                      newItems[strTime] = [];
                  }
              }
  
              return {
                  ...newItems
              };
  
          case "EVENTS_CALENDAR_MONTH": 
              // ...
  </code></pre>
  
  <p>However, now I get an error: cannot read property events of undefined. How can I declare my <code>events</code> outside of my <code>switch</code> without getting the error?</p>