title: typescript function throwing error to return a value
body: <p>Here is what I am trying to accomplish, I am calling a function getGeoLocationOfUser() which I supposed to return me the geolocation of user and function is supposed to return only when geolocation is available or there is some error.</p>
  
  <p>but above function is throwing an error <strong>A function whose declared type is neither 'void' nor 'any' must return a value.</strong></p>
  
  <pre><code>  public userGeolocation={latitude:null,longitude:null}
  
    getGeoLocationOfUser():{latitude:any,longitude:any}{
      this.geolocation.getCurrentPosition().then((resp) =&gt; {
      this.userGeolocation.latitude=resp.coords.latitude;
      this.userGeolocation.longitude=resp.coords.longitude;
      console.log(this.userGeolocation);
  
  localStorage.setItem('userGeoLocation',JSON.stringify(this.userGeolocation));
  return this.userGeolocation;
   //saving geolocation of user to localStorage
  
   }).catch((error) =&gt; {
    console.log('Error getting location', error);
    return this.userGeolocation;
  });
  }
  </code></pre>
  
  <p>I might be missing a very basic concept here .Any help will be appreciated.</p>