We want to access the user's location using the Geolocation API.
This snippet works fine:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position: GeolocationPosition) => console.log(position));
}
VSCode also doesn't show any errors or warnings, but the Angular CLI throws this error:
Cannot find name 'GeolocationPosition'.
navigator.geolocation.getCurrentPosition((position: GeolocationPosition) => console.log(position));
The project is using the following things:
- Angular 11.0.6
- tslib 2.0.0
- ts-node 8.3.0
- tslint 6.1.0
- typescript 4.0.2
Also strict type checking is enabled in Angular CLI
How to use this type and other types from that API correctly?