How to fix Function type '() => void' is not assignable to function type '() => undefined' in TypeScript | DevErrors