title: type check and spread operator (setState)
body: <p>Using spread operator or Object.assign will lose strict typescript check.</p>
  
  <pre><code>type State = {
    key1: string;
    key2: string;
  };
  
  function App() {
    const [state, setState] = React.useState&lt;State&gt;({
      key1: "",
      key2: ""
    });
    React.useEffect(() =&gt; {
      setState(prevState =&gt; {
        return { ...prevState, ...{ key3: "" } };//no ts error
      });
      setState(prevState =&gt; {
        return Object.assign({}, prevState, { key3: "" });//no ts error
      });
      setState({key1:'', key2:'', key3: ''});//ts error!!
    }, []);
    return &lt;div&gt;{JSON.stringify(state)}&lt;/div&gt;;
  }
  </code></pre>
  
  <p>I've try with Vanilla TS, still problem</p>
  
  <pre><code>type Person = {
      name: string,
      age: number
  }
  const person1:Person = {...{name: 'a', age: 20, salary: 20}};//no error
  const person2:Person = Object.assign({name: 'a', age: 20, salary: 20});//no error
  const person3:Person = {name: 'a', age: 20, salary: 20};//ts error
  </code></pre>
  
  <p><a href="https://www.typescriptlang.org/play/index.html#code/C4TwDgpgBAChBOBnA9gOygXigbwFBQKlQEMBbCALikWHgEtUBzAGn0OMcqIFdSAjBLgC+uAMZoaUSEjQBGCnBnos2AHTrsJclQDkxHcygcuAJgAMhxMQA2xeCCrmhQgNwB6N6mRQE8ZPDEJYCkEFFQTBVC0TCgAeT4AKwhRYFViREQ6RlQACk0yLj0DI05HC2obOwcoJwBKd09vX39A1ElpMIBmSKUY-O0oIsNjMstK+zLXD2BEH3g-eCA" rel="nofollow noreferrer">typescript playground link</a></p>
  
  <p>It seems there are some bugs with ts. I want to know if there is a simple way to update the state with strict type checking? Could anyone guide me through this?</p>