typescript conditional return type with undefined Below the function I currently have. But unfortunately I got the following error: