Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
How can I bypass ESLint calling the Geolocation interface undefined in Typescript?

I am utilizing the Geolocation API to place a marker on a map, but ESLint is complaining that GeolocationPosition is undefined. Nevertheless, the code runs and gives me the expected result, but I want to clean my code for warnings. I am new to typescript and ESlint, so I am unsure where to go from here. Any suggestions? Code and image of warning follows.

enter image description here

import { Map } from 'leaflet';
import { iconLocation, setMarker } from './leafletMarker';

export function getUserPosition(callback : (position : GeolocationPosition) => void) {
    function success(position : GeolocationPosition) {
        callback(position);
    }
    function error() {
        console.log('Unable to retrieve your location'); // change to alerts when Alert component is ready
    }
    if (!navigator.geolocation) {
        console.log('Geolocation is not supported by your browser'); // change to alerts when Alert component is ready
    } else {
        navigator.geolocation.getCurrentPosition(success, error, { enableHighAccuracy: true });
    }
}

export function handleMyPosition(map: Map) {
    getUserPosition((userPosition: GeolocationPosition) => {
        if (map) {
            const { latitude, longitude } = userPosition.coords;
            setMarker(map, latitude, longitude, { icon: iconLocation });
            map?.setView([latitude, longitude], 9);
        }
    });
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Don't use no-undef in TypeScript projects. Just disable the rule in your config, TypeScript does the same but better.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!