Typescript throwing error: “Spread types may only be created from object types.(2698)”

The code below throws an error when attempting to spread an object after a null check. The error shows subtask as type “never” and then says I can’t use spread because it’s not an object even though I’m clearly checking that subtask exists before spreading it into a new object.

Any idea why this is happening and how I can resolve this error without resorting to removing type safety around the object?

type SubTaskFlow = 'Subtask1' | 'Subtask2'
type Status = 'NotComplete' | 'Complete'
type SubTask = {
  flow: SubTaskFlow
  status: Status
}

type Task = {
  flow: 'Task1' | 'Task2'
  subtasks: Array<SubTask> 
   status: Status
}

type Tasks = Array<Task>

const obj1:Task = {
flow: 'Task1' , 
subtasks: [{flow: 'Subtask1', status: 'NotComplete'}, {flow: 'Subtask1', status: 'NotComplete'}],
status: 'NotComplete'
}
const obj2:Task = {
flow: 'Task2', 
subtasks: [{flow: 'Subtask1', status: 'NotComplete'}, {flow: 'Subtask2', status: 'NotComplete'}],
status: 'NotComplete'
}

const testFunc = (subtaskFlow: SubTaskFlow, status: Status) => {
const tasks = [obj1, obj2]

    let subtask: SubTask | null = null
    let subtaskToUpdateIndex: number = -1
    let taskWithSubtaskToUpdateIndex: number = -1

    tasks.forEach((task, taskIndex) => {
 
        if (task.subtasks && task.subtasks.length) {
          // iterate over the subtasks to check for match
          task.subtasks.forEach((_subtask, subtaskIndex) => {
            if (_subtask.flow === subtaskFlow) {
              subtask = _subtask
              subtaskToUpdateIndex = subtaskIndex
              taskWithSubtaskToUpdateIndex = taskIndex
            }
          })
        }
      })

    

      if(subtask){
        const testsubtask = {...subtask}
      }
}

This TS playground better demonstrates the error:
https://www.typescriptlang.org/play?#code/C4TwDgpgBAygrgIwCoEMDOBrAYgGwPYDuUAvFAOTwLDoYCMZUAPuZdZgExkCwAUKJLGrA4aEuQByeYAGE8AWzA4IwCA2ZlZCpSu59w0SqkxiA3ryhQAZvgIAuWIiPYb5qGiEj7MD2l4BfXl5+aCdTV2tCezIneiZyJ05XNEQ2DDR7AEEAJyyUEAAeQxoAPihXNx8vH39Anlqg-SgnUVJs3IKnYtqAYzwAO3coPAQAK1pbUNIzHgi7eJpYgBoynmSqGnSoAG0TWajWBbJl9xRhTbJJGXlFZVU-Zd2bfZTD48qJKU0bnT8AXUXeCczlFLl9tKoajxegNgENRuwJjQwjMnvMOEcVmtUpsdnsWC9MPQ3qdPB8rlpbmR7lBHpF8et0cTgWSwZS-gDVu8Lp9ruDdAE6lD+oMVO4sHA+t0xAAKLE0XB0oqYBUEJmk7wktAAShIpWm0JFGzEW2GY2WpvYv1qFgs2jcBIwXkcSOYfTgOBwYjdHvKUDtcswSDwAFUwAATU4QACSfTDEAAHvY3XIEBAsmIALS0X121IAdQAlsAABYHQMh8ORmNxxNQZOp9OkLPWm3YgB0ljwWQAoihusXpdLUstUtWEzriHrzL6bVAC5YoEOaG2A2koAAyddQVIrh1oNtKPoAcxLOums4vUAA9Fe5ypciohgA3NPb4vQVeiYB4KD9iDdDArC7KA5FOfsZwvHdPw7Lte37QcAH1V2OB0x3jCcpx4S9L3nRckIdDsbBIYhSFXFUzwg7D7QZQDSHwmjKOw1cg1DCMVDQsRVzQxjL3zItSwdFjK3Y2MEzEUdRPjHibQFKiLD8LVGNki8FJbCw1JtedZQdLVz2wg1YVFYBV1MNszNXZTZwFPwgA