title: JS Flow: How to initialize an empty object and set type as an argument to a function?
body: <p>I have a React reducer that sets an active user which is an object.  I want the initial state to be an empty object, <code>{}</code>.  However, I cannot figure out the syntax. This is my attempt:</p>
  
  <pre><code>// @flow
  import { SET_ACTIVE_USER } from '../actions/types';
  
  type action = {
    type: string,
    payload: Object,
  };
  
  const state: Object = {};
  
  export default (state: state, action: &lt;action&gt;) =&gt; {
    switch(action.type) {
      case SET_ACTIVE_USER:
        return action.payload;
    }
  
    return state;
  }
  </code></pre>
  
  <p>I have also tried doing this: 
  <code>(state: Object = {}, action: &lt;action&gt;)</code> but it doesn't work either.</p>
  
  <p>This is the full error message from running <code>flow</code>:</p>
  
  <p><code>12: export default (state: state, action: &lt;action&gt;) =&gt; {
                                   ^ Unexpected token ,</code></p>
  
  <p>Another attempt was to mimic the parameter that's working like this:</p>
  
  <pre><code>// @flow
  ...
  
  type state = {};
  
  export default (state: &lt;state&gt;, action: &lt;action&gt;) : Object =&gt; {
  ...
  </code></pre>
  
  <p>I have read through the documentation but I cannot find out the right syntax. </p>
  
  <p>I had a syntax error elsewhere and fixing it along with converting it to this appears to have worked. Unsure of why that would be the case.</p>
  
  <p><code>export default (state: Object = {}, action: action) : Object =&gt; {</code></p>
  
  <p>So, I guess my question becomes, what is the <strong>right</strong> way to do this?</p>
  
  <p>Thanks</p>