title: Property 'id' is optional in type A but required in type B after if statement
body: <p>TS 4.1.3. The Error is called as  <code>Argument of type 'Task' is not assignable to parameter of type '{ id: string; }'.   Property 'id' is optional in type 'Task' but required in type '{ id: string; }'.</code> The error occured in functions below</p>
  <pre><code>interface Task {
      id?: string
      message: string,
  }
  
  const handleClickTask = (task: Task) =&gt; {
      if (task.id) {
          getTask(task)
      }
  }
  
  const getTask = (taskWithId: { id: string }) =&gt; {
  
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/D01de.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D01de.jpg" alt="enter image description here" /></a></p>
  <p>Link to the TS playground <a href="https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgCpwM4GtkG8CwAUMicsACYD8AXMhmFKAOZGnIC2EGGcTEt9RiCYAaIgF8iRBAHsQ9ZAAs4IcgBsIAYTXAEWdNmQBeZAAowmLLQNYAlMYB8eVqWAwzF7ADoK9gsTZSPjAbc0tbFxJJQmjpOQVgm2MPSwB1YDBFAElyWlwyXLoGZmRxeyMnfwkgA" rel="nofollow noreferrer">https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgCpwM4GtkG8CwAUMicsACYD8AXMhmFKAOZGnIC2EGGcTEt9RiCYAaIgF8iRBAHsQ9ZAAs4IcgBsIAYTXAEWdNmQBeZAAowmLLQNYAlMYB8eVqWAwzF7ADoK9gsTZSPjAbc0tbFxJJQmjpOQVgm2MPSwB1YDBFAElyWlwyXLoGZmRxeyMnfwkgA</a></p>
  <p>How to fix it and why the error is occured?</p>