title: How to update the React state when a parameter of the state is a Map?
body: <p>The state of a React component in my app is of the following type:</p>
  <pre><code>interface ComponentState {
      messages: Map&lt;string, Messages[]&gt;;
  }
  </code></pre>
  <p>How to update the state of the component using setState?</p>
  <p>I tried the following, however it changes the <code>messages</code> to an <code>Object</code> from a <code>Map</code>. Also, the following is not caught by TypeScript.</p>
  <pre><code>this.setState((prevState) =&gt; ({
      messages: {
          ...prevState.messages,
          [someKeyAsString]: someValue,
      }
  }));
  </code></pre>
  <p>Is there a way to use a <code>Map</code> as a state property and update it in the proper way using <code>setState</code> and also not change the type of the parameter from <code>Map</code> to <code>Object</code></p>