How to fix Function lacks ending return statement and return type does not include 'undefined' in TypeScript | DevErrors