title: Using double type with useState and assigning based on type
body: <p>I have 2 classes, one extending other:</p>
  <pre><code>export class DoIt implements IDoIt { //some fields }
  </code></pre>
  <p>and</p>
  <pre><code>export class DoThat extends DoIt implements IDoThat { // one extra field }
  </code></pre>
  <p>Now, I can receive one of 2 responses, and based on it I would like to use the appropriate type.</p>
  <p>What I tried:</p>
  <pre><code>const [currentTask, setCurrentTask] = useState&lt;DoIt | DoThat&gt;();
  </code></pre>
  <p>and then (<code>task</code> is my response here):</p>
  <pre><code>  if(task instanceof DoThat)
            setCurrentTask(task as DoThat);
    else
            setCurrentTask(task as DoIt);
  </code></pre>
  <p>But <code>currentTask</code> is always of type <code>DoIt</code>, even if the extra field is present. Am I doing this correctly or missing something?</p>