Our goal is to utilize the Geolocation API to access the user's location.
This particular code snippet appears to be functioning well:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position: GeolocationPosition) => console.log(position));
}
Despite no errors or warnings in VSCode, an issue arises with the Angular CLI displaying this error message:
Cannot find name 'GeolocationPosition'.
navigator.geolocation.getCurrentPosition((position: GeolocationPosition) => console.log(position));
The project makes use of the following technologies:
- Angular 11.0.6
- tslib 2.0.0
- ts-node 8.3.0
- tslint 6.1.0
- typescript 4.0.2
Additionally, strict
type checking is enabled within Angular CLI
What is the correct way to properly utilize this type and other types from the Geolocation API?